damus

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

commit cc190c3618831ef8c73e3e4291301388adc2543d
parent c9c51c6d4ad7cb4ed102da8d097d799ff11a9e43
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  3 Apr 2023 09:47:15 -0700

Also broadcast event's user profile

This should help propagation of user profiles

Changelog-Changed: Broadcast now also broadcasts event user's profile

Diffstat:
Mdamus/ContentView.swift | 9++++++++-
Mdamus/Models/HomeModel.swift | 2+-
Mdamus/Views/Profile/ProfilePicView.swift | 2+-
Mdamus/Views/Profile/ProfileView.swift | 2+-
4 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/damus/ContentView.swift b/damus/ContentView.swift @@ -18,6 +18,7 @@ var BOOTSTRAP_RELAYS = [ struct TimestampedProfile { let profile: Profile let timestamp: Int64 + let event: NostrEvent } enum Sheets: Identifiable { @@ -382,7 +383,13 @@ struct ContentView: View { } .onReceive(handle_notify(.broadcast_event)) { obj in let ev = obj.object as! NostrEvent - self.damus_state?.pool.send(.event(ev)) + guard let ds = self.damus_state else { + return + } + ds.postbox.send(ev) + if let profile = ds.profiles.profiles[ev.pubkey] { + ds.postbox.send(profile.event) + } } .onReceive(handle_notify(.unfollow)) { notif in guard let privkey = self.privkey else { diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift @@ -667,7 +667,7 @@ func process_metadata_event(our_pubkey: String, profiles: Profiles, ev: NostrEve } } - let tprof = TimestampedProfile(profile: profile, timestamp: ev.created_at) + let tprof = TimestampedProfile(profile: profile, timestamp: ev.created_at, event: ev) profiles.add(id: ev.pubkey, profile: tprof) if let nip05 = profile.nip05, old_nip05 != profile.nip05 { diff --git a/damus/Views/Profile/ProfilePicView.swift b/damus/Views/Profile/ProfilePicView.swift @@ -172,7 +172,7 @@ 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, banner: "", website: "https://jb55.com", lud06: nil, lud16: nil, nip05: "jb55.com") - let ts_profile = TimestampedProfile(profile: profile, timestamp: 0) + let ts_profile = TimestampedProfile(profile: profile, timestamp: 0, event: test_event) profiles.add(id: pubkey, profile: ts_profile) return profiles } diff --git a/damus/Views/Profile/ProfileView.swift b/damus/Views/Profile/ProfileView.swift @@ -480,7 +480,7 @@ func test_damus_state() -> DamusState { let damus = DamusState.empty let prof = Profile(name: "damus", display_name: "damus", about: "iOS app!", picture: "https://damus.io/img/logo.png", banner: "", website: "https://damus.io", lud06: nil, lud16: "jb55@sendsats.lol", nip05: "damus.io") - let tsprof = TimestampedProfile(profile: prof, timestamp: 0) + let tsprof = TimestampedProfile(profile: prof, timestamp: 0, event: test_event) damus.profiles.add(id: pubkey, profile: tsprof) return damus }