damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 29140d956b5bdae2ebf9fbcda0283da2ff4eff9e
parent 7ae7584135d49121a15c386909f1c268359a6e72
Author: Daniel D'Aquino' via patches <patches@damus.io>
Date:   Sat, 15 Jul 2023 04:17:03 +0000

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>

Diffstat:
Mdamus/Views/Relays/RelayConfigView.swift | 17++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/damus/Views/Relays/RelayConfigView.swift b/damus/Views/Relays/RelayConfigView.swift @@ -12,6 +12,7 @@ struct RelayConfigView: View { @State var new_relay: String = "" @State var relays: [RelayDescriptor] @State private var showActionButtons = false + @State var relayAddErrorMessage: String? = nil @Environment(\.dismiss) var dismiss @@ -89,7 +90,14 @@ struct RelayConfigView: View { let info = RelayInfo.rw 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 } @@ -115,6 +123,13 @@ struct RelayConfigView: View { .padding(EdgeInsets(top: 15, leading: 0, bottom: 0, trailing: 0)) } } + if let errorMessage = relayAddErrorMessage { + HStack { + Spacer() + Text(errorMessage) + .foregroundColor(Color.red) + } + } } }