damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 972716882c12c6367e08edad780c101dd4b974aa
parent 81f3764e4bdcaf25787832d88019e7567d3afea3
Author: William Casarin <jb55@jb55.com>
Date:   Fri, 23 Dec 2022 09:20:44 -0800

profile: add ability to gets/set nip05

Diffstat:
Mdamus/Nostr/Nostr.swift | 8+++++++-
Mdamus/Views/ProfilePicView.swift | 2+-
Mdamus/Views/ProfileView.swift | 2+-
3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/damus/Nostr/Nostr.swift b/damus/Nostr/Nostr.swift @@ -10,7 +10,7 @@ import Foundation struct Profile: Codable { var value: [String: String] - init (name: String?, display_name: String?, about: String?, picture: String?, website: String?, lud06: String?, lud16: String?) { + init (name: String?, display_name: String?, about: String?, picture: String?, website: String?, lud06: String?, lud16: String?, nip05: String?) { self.value = [:] self.name = name self.display_name = display_name @@ -19,6 +19,7 @@ struct Profile: Codable { self.website = website self.lud06 = lud06 self.lud16 = lud16 + self.nip05 = nip05 } var display_name: String? { @@ -56,6 +57,11 @@ struct Profile: Codable { set(s) { value["lud16"] = s } } + var nip05: String? { + get { return value["nip05"]; } + set(s) { value["nip05"] = s } + } + var lightning_uri: URL? { return make_ln_url(self.lud06) ?? make_ln_url(self.lud16) } diff --git a/damus/Views/ProfilePicView.swift b/damus/Views/ProfilePicView.swift @@ -101,7 +101,7 @@ struct ProfilePicView: View { func make_preview_profiles(_ pubkey: String) -> Profiles { let profiles = Profiles() let picture = "http://cdn.jb55.com/img/red-me.jpg" - let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture, website: "https://jb55.com", lud06: nil, lud16: nil) + let profile = Profile(name: "jb55", display_name: "William Casarin", about: "It's me", picture: picture, website: "https://jb55.com", lud06: nil, lud16: nil, nip05: "jb55.com") let ts_profile = TimestampedProfile(profile: profile, timestamp: 0) profiles.add(id: pubkey, profile: ts_profile) return profiles diff --git a/damus/Views/ProfileView.swift b/damus/Views/ProfileView.swift @@ -211,7 +211,7 @@ func test_damus_state() -> DamusState { let pubkey = "3efdaebb1d8923ebd99c9e7ace3b4194ab45512e2be79c1b7d68d9243e0d2681" let damus = DamusState(pool: RelayPool(), keypair: Keypair(pubkey: pubkey, privkey: "privkey"), likes: EventCounter(our_pubkey: pubkey), boosts: EventCounter(our_pubkey: pubkey), contacts: Contacts(), tips: TipCounter(our_pubkey: pubkey), profiles: Profiles(), dms: DirectMessagesModel()) - let prof = Profile(name: "damus", display_name: "Damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol") + let prof = Profile(name: "damus", display_name: "Damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol", nip05: "damus.io") let tsprof = TimestampedProfile(profile: prof, timestamp: 0) damus.profiles.add(id: pubkey, profile: tsprof) return damus