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>
This commit is contained in:
Daniel D’Aquino
2025-05-05 16:49:09 -07:00
parent eb4e3b692b
commit aef516ae9f
3 changed files with 27 additions and 13 deletions

View File

@@ -11,12 +11,14 @@ struct RelayView: View {
let state: DamusState let state: DamusState
let relay: RelayURL let relay: RelayURL
let recommended: Bool let recommended: Bool
/// Disables navigation link
let disableNavLink: Bool
@ObservedObject private var model_cache: RelayModelCache @ObservedObject private var model_cache: RelayModelCache
@State var relay_state: Bool @State var relay_state: Bool
@Binding var showActionButtons: 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.state = state
self.relay = relay self.relay = relay
self.recommended = recommended self.recommended = recommended
@@ -24,6 +26,7 @@ struct RelayView: View {
_showActionButtons = showActionButtons _showActionButtons = showActionButtons
let relay_state = RelayView.get_relay_state(pool: state.nostrNetwork.pool, relay: relay) let relay_state = RelayView.get_relay_state(pool: state.nostrNetwork.pool, relay: relay)
self._relay_state = State(initialValue: relay_state) self._relay_state = State(initialValue: relay_state)
self.disableNavLink = disableNavLink
} }
static func get_relay_state(pool: RelayPool, relay: RelayURL) -> Bool { static func get_relay_state(pool: RelayPool, relay: RelayURL) -> Bool {
@@ -96,10 +99,12 @@ struct RelayView: View {
RelayStatusView(connection: relay_connection) RelayStatusView(connection: relay_connection)
} }
Image("chevron-large-right") if !disableNavLink {
.resizable() Image("chevron-large-right")
.frame(width: 15, height: 15) .resizable()
.foregroundColor(.gray) .frame(width: 15, height: 15)
.foregroundColor(.gray)
}
} }
} }
.contentShape(Rectangle()) .contentShape(Rectangle())
@@ -108,7 +113,9 @@ struct RelayView: View {
self.relay_state = RelayView.get_relay_state(pool: state.nostrNetwork.pool, relay: self.relay) self.relay_state = RelayView.get_relay_state(pool: state.nostrNetwork.pool, relay: self.relay)
} }
.onTapGesture { .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))
}
} }
} }

View File

@@ -70,7 +70,7 @@ struct ConnectWalletView: View {
Spacer() Spacer()
NWCSettings.AccountDetailsView(nwc: nwc) NWCSettings.AccountDetailsView(nwc: nwc, damus_state: nil)
Spacer() Spacer()

View File

@@ -134,7 +134,7 @@ struct NWCSettings: View {
SupportDamus SupportDamus
.padding(.bottom) .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) 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) .toggleStyle(.switch)
@@ -185,6 +185,7 @@ struct NWCSettings: View {
struct AccountDetailsView: View { struct AccountDetailsView: View {
let nwc: WalletConnect.ConnectURL let nwc: WalletConnect.ConnectURL
let damus_state: DamusState?
var body: some View { var body: some View {
VStack(alignment: .leading) { 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") 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) .font(.headline)
Text(nwc.relay.absoluteString) if let damus_state {
.font(.body) RelayView(state: damus_state, relay: nwc.relay, showActionButtons: .constant(false), recommended: false, disableNavLink: true)
.fontWeight(.bold) .padding(.bottom)
.foregroundColor(.gray) }
.padding(.bottom) else {
Text(nwc.relay.absoluteString)
.font(.body)
.fontWeight(.bold)
.foregroundColor(.gray)
.padding(.bottom)
}
if let lud16 = nwc.lud16 { if let lud16 = nwc.lud16 {
Text("Account", comment: "Label for the user account information with the Nostr Wallet Connect wallet provider.") Text("Account", comment: "Label for the user account information with the Nostr Wallet Connect wallet provider.")