commit aef516ae9fb501484da36c271a3470ff12986188
parent eb4e3b692b281d881c9063d33b3b4eda1e29d345
Author: Daniel D’Aquino <daniel@daquino.me>
Date: Mon, 5 May 2025 16:49:09 -0700
Add relay connectivity information to NWC settings
Changelog-Changed: Added relay connectivity information to NWC settings
Signed-off-by: Daniel D’Aquino <daniel@daquino.me>
Diffstat:
3 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/damus/Views/Relays/RelayView.swift b/damus/Views/Relays/RelayView.swift
@@ -11,12 +11,14 @@ struct RelayView: View {
let state: DamusState
let relay: RelayURL
let recommended: Bool
+ /// Disables navigation link
+ let disableNavLink: Bool
@ObservedObject private var model_cache: RelayModelCache
@State var relay_state: Bool
@Binding var showActionButtons: Bool
- init(state: DamusState, relay: RelayURL, showActionButtons: Binding<Bool>, recommended: Bool) {
+ init(state: DamusState, relay: RelayURL, showActionButtons: Binding<Bool>, recommended: Bool, disableNavLink: Bool = false) {
self.state = state
self.relay = relay
self.recommended = recommended
@@ -24,6 +26,7 @@ struct RelayView: View {
_showActionButtons = showActionButtons
let relay_state = RelayView.get_relay_state(pool: state.nostrNetwork.pool, relay: relay)
self._relay_state = State(initialValue: relay_state)
+ self.disableNavLink = disableNavLink
}
static func get_relay_state(pool: RelayPool, relay: RelayURL) -> Bool {
@@ -96,10 +99,12 @@ struct RelayView: View {
RelayStatusView(connection: relay_connection)
}
- Image("chevron-large-right")
- .resizable()
- .frame(width: 15, height: 15)
- .foregroundColor(.gray)
+ if !disableNavLink {
+ Image("chevron-large-right")
+ .resizable()
+ .frame(width: 15, height: 15)
+ .foregroundColor(.gray)
+ }
}
}
.contentShape(Rectangle())
@@ -108,7 +113,9 @@ struct RelayView: View {
self.relay_state = RelayView.get_relay_state(pool: state.nostrNetwork.pool, relay: self.relay)
}
.onTapGesture {
- state.nav.push(route: Route.RelayDetail(relay: relay, metadata: model_cache.model(with_relay_id: relay)?.metadata))
+ if !disableNavLink {
+ state.nav.push(route: Route.RelayDetail(relay: relay, metadata: model_cache.model(with_relay_id: relay)?.metadata))
+ }
}
}
diff --git a/damus/Views/Wallet/ConnectWalletView.swift b/damus/Views/Wallet/ConnectWalletView.swift
@@ -70,7 +70,7 @@ struct ConnectWalletView: View {
Spacer()
- NWCSettings.AccountDetailsView(nwc: nwc)
+ NWCSettings.AccountDetailsView(nwc: nwc, damus_state: nil)
Spacer()
diff --git a/damus/Views/Wallet/NWCSettings.swift b/damus/Views/Wallet/NWCSettings.swift
@@ -134,7 +134,7 @@ struct NWCSettings: View {
SupportDamus
.padding(.bottom)
- AccountDetailsView(nwc: nwc)
+ AccountDetailsView(nwc: nwc, damus_state: damus_state)
Toggle(NSLocalizedString("Disable high balance warning", comment: "Setting to disable high balance warnings on the user's wallet"), isOn: $settings.dismiss_wallet_high_balance_warning)
.toggleStyle(.switch)
@@ -185,6 +185,7 @@ struct NWCSettings: View {
struct AccountDetailsView: View {
let nwc: WalletConnect.ConnectURL
+ let damus_state: DamusState?
var body: some View {
VStack(alignment: .leading) {
@@ -198,11 +199,17 @@ struct NWCSettings: View {
Text("Routing", comment: "Label indicating the routing address for Nostr Wallet Connect payments. In other words, the relay used by the NWC wallet provider")
.font(.headline)
- Text(nwc.relay.absoluteString)
- .font(.body)
- .fontWeight(.bold)
- .foregroundColor(.gray)
- .padding(.bottom)
+ if let damus_state {
+ RelayView(state: damus_state, relay: nwc.relay, showActionButtons: .constant(false), recommended: false, disableNavLink: true)
+ .padding(.bottom)
+ }
+ else {
+ Text(nwc.relay.absoluteString)
+ .font(.body)
+ .fontWeight(.bold)
+ .foregroundColor(.gray)
+ .padding(.bottom)
+ }
if let lud16 = nwc.lud16 {
Text("Account", comment: "Label for the user account information with the Nostr Wallet Connect wallet provider.")