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>
This commit is contained in:
William Casarin
2022-08-10 12:11:04 -07:00
parent 65710eeb5e
commit 39ab555a77
2 changed files with 19 additions and 3 deletions

View File

@@ -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
}