diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift index 789d809..342db84 100644 --- a/damus/Models/HomeModel.swift +++ b/damus/Models/HomeModel.swift @@ -338,7 +338,7 @@ class HomeModel: ObservableObject { } func should_hide_event(_ ev: NostrEvent) -> Bool { - return false + return !ev.should_show_event } func handle_text_event(sub_id: String, _ ev: NostrEvent) { diff --git a/damus/Models/ProfileModel.swift b/damus/Models/ProfileModel.swift index ff16db6..bd27bec 100644 --- a/damus/Models/ProfileModel.swift +++ b/damus/Models/ProfileModel.swift @@ -68,6 +68,10 @@ class ProfileModel: ObservableObject { } func add_event(_ ev: NostrEvent) { + guard ev.should_show_event else { + return + } + if seen_event.contains(ev.id) { return } diff --git a/damus/Models/SearchHomeModel.swift b/damus/Models/SearchHomeModel.swift index 06d88db..834d105 100644 --- a/damus/Models/SearchHomeModel.swift +++ b/damus/Models/SearchHomeModel.swift @@ -62,7 +62,7 @@ class SearchHomeModel: ObservableObject { guard sub_id == self.base_subid || sub_id == self.profiles_subid else { return } - if ev.kind == NostrKind.text.rawValue { + if ev.is_textlike && ev.should_show_event { if seen_pubkey.contains(ev.pubkey) { return } diff --git a/damus/Models/SearchModel.swift b/damus/Models/SearchModel.swift index 7659d1e..14fccb3 100644 --- a/damus/Models/SearchModel.swift +++ b/damus/Models/SearchModel.swift @@ -52,7 +52,7 @@ class SearchModel: ObservableObject { func handle_event(relay_id: String, ev: NostrConnectionEvent) { let done = handle_subid_event(pool: pool, sub_id: sub_id, relay_id: relay_id, ev: ev) { ev in - if ev.known_kind == .text { + if ev.known_kind == .text && ev.should_show_event { self.add_event(ev) } } diff --git a/damus/Models/ThreadModel.swift b/damus/Models/ThreadModel.swift index 8880a0a..1dc726d 100644 --- a/damus/Models/ThreadModel.swift +++ b/damus/Models/ThreadModel.swift @@ -148,6 +148,10 @@ class ThreadModel: ObservableObject { } func add_event(_ ev: NostrEvent, privkey: String?) { + guard ev.should_show_event else { + return + } + if event_map[ev.id] != nil { return } diff --git a/damus/Nostr/NostrEvent.swift b/damus/Nostr/NostrEvent.swift index 2f62d76..76042d0 100644 --- a/damus/Nostr/NostrEvent.swift +++ b/damus/Nostr/NostrEvent.swift @@ -55,6 +55,18 @@ class NostrEvent: Codable, Identifiable, CustomStringConvertible { let created_at: Int64 let kind: Int let content: String + + var is_textlike: Bool { + return kind == 1 || kind == 42 + } + + var too_big: Bool { + return self.content.count > 32000 + } + + var should_show_event: Bool { + return !too_big + } private var _blocks: [Block]? = nil func blocks(_ privkey: String?) -> [Block] {