damus

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

commit 39ab555a77cafc75f413c97187f9545c72dfda00
parent 65710eeb5e3897b0b7eb377678e1f7131497e35f
Author: William Casarin <jb55@jb55.com>
Date:   Wed, 10 Aug 2022 12:11:04 -0700

Fix loading bug when opening boosted posts

Changelog-Fixed: Fixed thread loading issue when clicking on boosts
Signed-off-by: William Casarin <jb55@jb55.com>

Diffstat:
Mdamus/Nostr/NostrEvent.swift | 17+++++++++++++++--
Mdamus/Views/TimelineView.swift | 5++++-
2 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift @@ -101,9 +101,13 @@ class NostrEvent: Codable, Identifiable, CustomStringConvertible, Equatable { } lazy var inner_event: NostrEvent? = { - return event_from_json(dat: self.content) + // don't try to deserialize an inner event if we know there won't be one + if self.known_kind == .boost { + return event_from_json(dat: self.content) + } + return nil }() - + private var _event_refs: [EventRef]? = nil func event_refs(_ privkey: String?) -> [EventRef] { if let rs = _event_refs { @@ -739,3 +743,12 @@ func validate_event(ev: NostrEvent) -> ValidationResult { ok = secp256k1_schnorrsig_verify(ctx, &sig64, &raw_id_bytes, raw_id.count, &xonly_pubkey) > 0 return ok ? .ok : .bad_sig } + + +func inner_event_or_self(ev: NostrEvent) -> NostrEvent { + guard let inner_ev = ev.inner_event else { + return ev + } + + return inner_ev +} diff --git a/damus/Views/TimelineView.swift b/damus/Views/TimelineView.swift @@ -20,7 +20,9 @@ struct InnerTimelineView: View { var body: some View { LazyVStack { ForEach(events, id: \.id) { (ev: NostrEvent) in - let tv = ThreadView(thread: ThreadModel(event: ev, pool: damus.pool, privkey: damus.keypair.privkey), damus: damus, is_chatroom: has_hashtag(ev.tags, hashtag: "chat")) + let tm = ThreadModel(event: inner_event_or_self(ev: ev), pool: damus.pool, privkey: damus.keypair.privkey) + let is_chatroom = has_hashtag(ev.tags, hashtag: "chat") + let tv = ThreadView(thread: tm, damus: damus, is_chatroom: is_chatroom) NavigationLink(destination: tv) { EventView(event: ev, highlight: .none, has_action_bar: true, damus: damus, show_friend_icon: show_friend_icon) @@ -80,3 +82,4 @@ struct NavigationLazyView<Content: View>: View { build() } } +