mute: adding filtering support for MuteItem events

This patch depends on: Receiving New Mute List Type

- Changes NewMutesNotify, NewUnmutesNotify & MuteNotify to use MuteItem instead of Pubkey
- Changes is_muted in Contacts.swift to take in a MuteItem instead of a Pubkey
    - A lot of changes here were just modifying callers of that to accept the new parameter type

Related: https://github.com/damus-io/damus/issues/1718
Related: https://github.com/damus-io/damus/issues/856
Lighting Address: fishcharlie@strike.me

Signed-off-by: Charlie Fish <contact@charlie.fish>
Reviewed-by: William Casarin <jb55@jb55.com>
Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
Charlie Fish
2024-01-17 18:17:40 -07:00
committed by William Casarin
parent 2861ee2c12
commit 61a9e44898
11 changed files with 43 additions and 49 deletions

View File

@@ -278,11 +278,11 @@ class HomeModel {
func filter_events() {
events.filter { ev in
!damus_state.contacts.is_muted(ev.pubkey)
!damus_state.contacts.is_muted(.user(ev.pubkey, nil))
}
self.dms.dms = dms.dms.filter { ev in
!damus_state.contacts.is_muted(ev.pubkey)
!damus_state.contacts.is_muted(.user(ev.pubkey, nil))
}
notifications.filter { ev in
@@ -290,7 +290,8 @@ class HomeModel {
return false
}
return !damus_state.contacts.is_muted(ev.pubkey) && !damus_state.muted_threads.isMutedThread(ev, keypair: damus_state.keypair)
let event_muted = damus_state.contacts.mutelist?.mute_list?.event_muted_reason(ev) != nil
return !event_muted
}
}
@@ -1093,11 +1094,8 @@ func should_show_event(event: NostrEvent, damus_state: DamusState) -> Bool {
}
func should_show_event(keypair: Keypair, hellthreads: MutedThreadsManager, contacts: Contacts, ev: NostrEvent) -> Bool {
if contacts.is_muted(ev.pubkey) {
return false
}
if hellthreads.isMutedThread(ev, keypair: keypair) {
let event_muted = contacts.mutelist?.mute_list?.event_muted_reason(ev) != nil
if event_muted {
return false
}