Allow relay logs to be opened in dev mode even if relay is disconnected

Changelog-Fixed: Allow relay logs to be opened in dev mode even if relay
Closes: https://github.com/damus-io/damus/issues/1368
Signed-off-by: Daniel D'Aquino <daniel@daquino.me>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Daniel D'Aquino' via patches
2023-07-28 01:30:35 +00:00
committed by William Casarin
parent 4fecf72963
commit 815f4d4a96
3 changed files with 39 additions and 31 deletions

View File

@@ -12,7 +12,7 @@ enum Route: Hashable {
case Profile(profile: ProfileModel, followers: FollowersModel) case Profile(profile: ProfileModel, followers: FollowersModel)
case Followers(followers: FollowersModel) case Followers(followers: FollowersModel)
case Relay(relay: String, showActionButtons: Binding<Bool>) case Relay(relay: String, showActionButtons: Binding<Bool>)
case RelayDetail(relay: String, metadata: RelayMetadata) case RelayDetail(relay: String, metadata: RelayMetadata?)
case Following(following: FollowingModel) case Following(following: FollowingModel)
case MuteList(users: [String]) case MuteList(users: [String])
case RelayConfig case RelayConfig

View File

@@ -10,13 +10,13 @@ import SwiftUI
struct RelayDetailView: View { struct RelayDetailView: View {
let state: DamusState let state: DamusState
let relay: String let relay: String
let nip11: RelayMetadata let nip11: RelayMetadata?
@ObservedObject var log: RelayLog @ObservedObject var log: RelayLog
@Environment(\.dismiss) var dismiss @Environment(\.dismiss) var dismiss
init(state: DamusState, relay: String, nip11: RelayMetadata) { init(state: DamusState, relay: String, nip11: RelayMetadata?) {
self.state = state self.state = state
self.relay = relay self.relay = relay
self.nip11 = nip11 self.nip11 = nip11
@@ -83,7 +83,7 @@ struct RelayDetailView: View {
} }
} }
if let pubkey = nip11.pubkey { if let pubkey = nip11?.pubkey {
Section(NSLocalizedString("Admin", comment: "Label to display relay contact user.")) { Section(NSLocalizedString("Admin", comment: "Label to display relay contact user.")) {
UserViewRow(damus_state: state, pubkey: pubkey) UserViewRow(damus_state: state, pubkey: pubkey)
.onTapGesture { .onTapGesture {
@@ -100,37 +100,40 @@ struct RelayDetailView: View {
} }
} }
} }
if nip11.is_paid {
Section(content: {
RelayPaidDetail(payments_url: nip11.payments_url)
}, header: {
Text("Paid Relay", comment: "Section header that indicates the relay server requires payment.")
}, footer: {
Text("This is a paid relay, you must pay for notes to be accepted.", comment: "Footer description that explains that the relay server requires payment to post.")
})
}
Section(NSLocalizedString("Description", comment: "Label to display relay description.")) { if let nip11 = nip11 {
FieldText(nip11.description) if nip11.is_paid {
} Section(content: {
Section(NSLocalizedString("Contact", comment: "Label to display relay contact information.")) { RelayPaidDetail(payments_url: nip11.payments_url)
FieldText(nip11.contact) }, header: {
} Text("Paid Relay", comment: "Section header that indicates the relay server requires payment.")
Section(NSLocalizedString("Software", comment: "Label to display relay software.")) { }, footer: {
FieldText(nip11.software) Text("This is a paid relay, you must pay for notes to be accepted.", comment: "Footer description that explains that the relay server requires payment to post.")
} })
Section(NSLocalizedString("Version", comment: "Label to display relay software version.")) { }
FieldText(nip11.version)
} Section(NSLocalizedString("Description", comment: "Label to display relay description.")) {
if let nips = nip11.supported_nips, nips.count > 0 { FieldText(nip11.description)
Section(NSLocalizedString("Supported NIPs", comment: "Label to display relay's supported NIPs.")) { }
Text(nipsList(nips: nips)) Section(NSLocalizedString("Contact", comment: "Label to display relay contact information.")) {
FieldText(nip11.contact)
}
Section(NSLocalizedString("Software", comment: "Label to display relay software.")) {
FieldText(nip11.software)
}
Section(NSLocalizedString("Version", comment: "Label to display relay software version.")) {
FieldText(nip11.version)
}
if let nips = nip11.supported_nips, nips.count > 0 {
Section(NSLocalizedString("Supported NIPs", comment: "Label to display relay's supported NIPs.")) {
Text(nipsList(nips: nips))
}
} }
} }
if state.settings.developer_mode, let log_contents = log.contents { if state.settings.developer_mode {
Section(NSLocalizedString("Log", comment: "Label to display developer mode logs.")) { Section(NSLocalizedString("Log", comment: "Label to display developer mode logs.")) {
Text(log_contents) Text(log.contents ?? NSLocalizedString("No logs to display", comment: "Label to indicate that there are no developer mode logs available to be displayed on the screen"))
.font(.system(size: 13)) .font(.system(size: 13))
.lineLimit(nil) .lineLimit(nil)
.fixedSize(horizontal: false, vertical: true) .fixedSize(horizontal: false, vertical: true)
@@ -141,7 +144,7 @@ struct RelayDetailView: View {
.onReceive(handle_notify(.switched_timeline)) { notif in .onReceive(handle_notify(.switched_timeline)) { notif in
dismiss() dismiss()
} }
.navigationTitle(nip11.name ?? "") .navigationTitle(nip11?.name ?? relay)
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)
} }

View File

@@ -51,6 +51,11 @@ struct RelayView: View {
.foregroundColor(Color.accentColor) .foregroundColor(Color.accentColor)
} else { } else {
Text(relay) Text(relay)
.background(
NavigationLink(value: Route.RelayDetail(relay: relay, metadata: nil), label: {
EmptyView()
}).opacity(0.0).disabled(showActionButtons)
)
Spacer() Spacer()