mirror of
git://jb55.com/damus
synced 2024-09-19 11:43:44 +00:00
Add feedback message when user adds a relay already in the list
Changelog-Added: Added feedback when user adds a relay that is already on the list Closes: https://github.com/damus-io/damus/issues/1053 Signed-off-by: Daniel D'Aquino <daniel@daquino.me> Reviewed-by: William Casarin <jb55@jb55.com> Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
parent
7ae7584135
commit
29140d956b
@ -12,6 +12,7 @@ struct RelayConfigView: View {
|
|||||||
@State var new_relay: String = ""
|
@State var new_relay: String = ""
|
||||||
@State var relays: [RelayDescriptor]
|
@State var relays: [RelayDescriptor]
|
||||||
@State private var showActionButtons = false
|
@State private var showActionButtons = false
|
||||||
|
@State var relayAddErrorMessage: String? = nil
|
||||||
|
|
||||||
@Environment(\.dismiss) var dismiss
|
@Environment(\.dismiss) var dismiss
|
||||||
|
|
||||||
@ -89,7 +90,14 @@ struct RelayConfigView: View {
|
|||||||
|
|
||||||
let info = RelayInfo.rw
|
let info = RelayInfo.rw
|
||||||
let descriptor = RelayDescriptor(url: url, info: info)
|
let descriptor = RelayDescriptor(url: url, info: info)
|
||||||
guard (try? state.pool.add_relay(descriptor)) != nil else {
|
|
||||||
|
do {
|
||||||
|
try state.pool.add_relay(descriptor)
|
||||||
|
relayAddErrorMessage = nil // Clear error message
|
||||||
|
} catch RelayError.RelayAlreadyExists {
|
||||||
|
relayAddErrorMessage = NSLocalizedString("This relay is already in your list", comment: "An error message that appears when the user attempts to add a relay that has already been added.")
|
||||||
|
return
|
||||||
|
} catch {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,6 +123,13 @@ struct RelayConfigView: View {
|
|||||||
.padding(EdgeInsets(top: 15, leading: 0, bottom: 0, trailing: 0))
|
.padding(EdgeInsets(top: 15, leading: 0, bottom: 0, trailing: 0))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if let errorMessage = relayAddErrorMessage {
|
||||||
|
HStack {
|
||||||
|
Spacer()
|
||||||
|
Text(errorMessage)
|
||||||
|
.foregroundColor(Color.red)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user