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 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))
}
}
}

View File

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

View File

@@ -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.")