commit e8b23daa3d5809377b551d4b8780ccfa5ec6608d
parent a2eb77a5e961b4ee4ce98371bb9f3a490937e0fa
Author: Terry Yiu <963907+tyiu@users.noreply.github.com>
Date: Mon, 6 Feb 2023 10:57:28 -0500
Fix UX to open relay config view when navigating from personal profile
Changelog-Changed: When on your profile page, open relay view instead for your own relays
Closes: #541
Diffstat:
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift
@@ -333,10 +333,19 @@ struct ProfileView: View {
}
if let relays = profile.relays {
- NavigationLink(destination: UserRelaysView(state: damus_state, pubkey: profile.pubkey, relays: Array(relays.keys).sorted())) {
- Text("\(Text("\(relays.keys.count)", comment: "Number of relay servers a user is connected.").font(.subheadline.weight(.medium))) \(Text(String(format: NSLocalizedString("relays_count", comment: "Part of a larger sentence to describe how many relay servers a user is connected."), relays.keys.count)).font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many relay servers a user is connected. In source English, the first variable is the number of relay servers, and the second variable is 'Relay' or 'Relays'.")
+ // Only open relay config view if the user is logged in with private key and they are looking at their own profile.
+ let relay_text = Text("\(Text("\(relays.keys.count)", comment: "Number of relay servers a user is connected.").font(.subheadline.weight(.medium))) \(Text(String(format: NSLocalizedString("relays_count", comment: "Part of a larger sentence to describe how many relay servers a user is connected."), relays.keys.count)).font(.subheadline).foregroundColor(.gray))", comment: "Sentence composed of 2 variables to describe how many relay servers a user is connected. In source English, the first variable is the number of relay servers, and the second variable is 'Relay' or 'Relays'.")
+ if profile.pubkey == damus_state.pubkey && damus_state.is_privkey_user {
+ NavigationLink(destination: RelayConfigView(state: damus_state)) {
+ relay_text
+ }
+ .buttonStyle(PlainButtonStyle())
+ } else {
+ NavigationLink(destination: UserRelaysView(state: damus_state, pubkey: profile.pubkey, relays: Array(relays.keys).sorted())) {
+ relay_text
+ }
+ .buttonStyle(PlainButtonStyle())
}
- .buttonStyle(PlainButtonStyle())
}
}
}