diff --git a/damus/Nostr/Nostr.swift b/damus/Nostr/Nostr.swift index 909cb3f..7cdb1cc 100644 --- a/damus/Nostr/Nostr.swift +++ b/damus/Nostr/Nostr.swift @@ -89,7 +89,8 @@ struct Profile: Codable { } static func displayName(profile: Profile?, pubkey: String) -> String { - return profile?.name ?? abbrev_pubkey(pubkey) + let pk = bech32_nopre_pubkey(pubkey) ?? pubkey + return profile?.name ?? abbrev_pubkey(pk) } } diff --git a/damus/Util/Keys.swift b/damus/Util/Keys.swift index e7b0009..d741cba 100644 --- a/damus/Util/Keys.swift +++ b/damus/Util/Keys.swift @@ -66,6 +66,13 @@ func bech32_pubkey(_ pubkey: String) -> String? { return bech32_encode(hrp: "npub", bytes) } +func bech32_nopre_pubkey(_ pubkey: String) -> String? { + guard let bytes = hex_decode(pubkey) else { + return nil + } + return bech32_encode(hrp: "", bytes) +} + func bech32_note_id(_ evid: String) -> String? { guard let bytes = hex_decode(evid) else { return nil diff --git a/damus/Views/MentionView.swift b/damus/Views/MentionView.swift index 66b4382..e0fbbb0 100644 --- a/damus/Views/MentionView.swift +++ b/damus/Views/MentionView.swift @@ -14,7 +14,8 @@ struct MentionView: View { var body: some View { switch mention.type { case .pubkey: - PubkeyView(pubkey: mention.ref.ref_id, relay: mention.ref.relay_id) + let pk = bech32_pubkey(mention.ref.ref_id) ?? mention.ref.ref_id + PubkeyView(pubkey: pk, relay: mention.ref.relay_id) case .event: Text("< e >") //EventBlockView(pubkey: mention.ref.ref_id, relay: mention.ref.relay_id) diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift index 55c8794..4439f2a 100644 --- a/damus/Views/NoteContentView.swift +++ b/damus/Views/NoteContentView.swift @@ -115,8 +115,8 @@ func mention_str(_ m: Mention, profiles: Profiles) -> String { let disp = Profile.displayName(profile: profile, pubkey: pk) return "[@\(disp)](nostr:\(encode_pubkey_uri(m.ref)))" case .event: - let evid = m.ref.ref_id - return "[&\(abbrev_pubkey(evid))](nostr:\(encode_event_id_uri(m.ref)))" + let bevid = bech32_note_id(m.ref.ref_id) ?? m.ref.ref_id + return "[@\(abbrev_pubkey(bevid))](nostr:\(encode_event_id_uri(m.ref)))" } } diff --git a/damus/Views/ProfileName.swift b/damus/Views/ProfileName.swift index 4b0dce7..6bd1edb 100644 --- a/damus/Views/ProfileName.swift +++ b/damus/Views/ProfileName.swift @@ -73,7 +73,6 @@ struct ProfileName: View { var body: some View { HStack { - Text(prefix + String(display_name ?? Profile.displayName(profile: profile, pubkey: pubkey))) .font(.body) .fontWeight(prefix == "@" ? .none : .bold) diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift index 1fde336..6e80453 100644 --- a/damus/Views/ProfileView.swift +++ b/damus/Views/ProfileView.swift @@ -161,12 +161,12 @@ struct ProfileView: View { let data = damus_state.profiles.lookup(id: profile.pubkey) HStack(alignment: .center) { - ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE, highlight: .custom(Color.black, 2), profiles: damus_state.profiles) + ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE, highlight: .none, profiles: damus_state.profiles) .onTapGesture { is_zoomed.toggle() } .sheet(isPresented: $is_zoomed) { - ProfilePicView(pubkey: profile.pubkey, size: zoom_size, highlight: .custom(Color.black, 2), profiles: damus_state.profiles) + ProfilePicView(pubkey: profile.pubkey, size: zoom_size, highlight: .none, profiles: damus_state.profiles) } Spacer()