Mute hellthreads everywhere
Changelog-Fixed: Mute hellthreads everywhere Fixes: https://damus.io/note1rn3ckl76myga6xcefr0le52d8czd0wqe8apguewqknyv7m55mmpq3rv3hv
This commit is contained in:
@@ -562,15 +562,9 @@ class HomeModel {
|
|||||||
|
|
||||||
func handle_notification(ev: NostrEvent) {
|
func handle_notification(ev: NostrEvent) {
|
||||||
// don't show notifications from ourselves
|
// don't show notifications from ourselves
|
||||||
guard ev.pubkey != damus_state.pubkey else {
|
guard ev.pubkey != damus_state.pubkey,
|
||||||
return
|
event_has_our_pubkey(ev, our_pubkey: self.damus_state.pubkey),
|
||||||
}
|
should_show_event(privkey: self.damus_state.keypair.privkey, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: ev) else {
|
||||||
|
|
||||||
guard event_has_our_pubkey(ev, our_pubkey: self.damus_state.pubkey) else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
guard should_show_event(contacts: damus_state.contacts, ev: ev) && !damus_state.muted_threads.isMutedThread(ev, privkey: damus_state.keypair.privkey) else {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -608,7 +602,7 @@ class HomeModel {
|
|||||||
|
|
||||||
|
|
||||||
func handle_text_event(sub_id: String, _ ev: NostrEvent) {
|
func handle_text_event(sub_id: String, _ ev: NostrEvent) {
|
||||||
guard should_show_event(contacts: damus_state.contacts, ev: ev) else {
|
guard should_show_event(privkey: damus_state.keypair.privkey, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: ev) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -635,7 +629,7 @@ class HomeModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handle_dm(_ ev: NostrEvent) {
|
func handle_dm(_ ev: NostrEvent) {
|
||||||
guard should_show_event(contacts: damus_state.contacts, ev: ev) else {
|
guard should_show_event(privkey: damus_state.keypair.privkey, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: ev) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1100,10 +1094,15 @@ func event_has_our_pubkey(_ ev: NostrEvent, our_pubkey: Pubkey) -> Bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func should_show_event(contacts: Contacts, ev: NostrEvent) -> Bool {
|
func should_show_event(privkey: Privkey?, hellthreads: MutedThreadsManager, contacts: Contacts, ev: NostrEvent) -> Bool {
|
||||||
if contacts.is_muted(ev.pubkey) {
|
if contacts.is_muted(ev.pubkey) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hellthreads.isMutedThread(ev, privkey: privkey) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return ev.should_show_event
|
return ev.should_show_event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ class SearchHomeModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func filter_muted() {
|
func filter_muted() {
|
||||||
events.filter { should_show_event(contacts: damus_state.contacts, ev: $0) }
|
events.filter { should_show_event(privkey: damus_state.keypair.privkey, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: $0) }
|
||||||
self.objectWillChange.send()
|
self.objectWillChange.send()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,8 @@ class SearchHomeModel: ObservableObject {
|
|||||||
guard sub_id == self.base_subid || sub_id == self.profiles_subid else {
|
guard sub_id == self.base_subid || sub_id == self.profiles_subid else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ev.is_textlike && should_show_event(contacts: damus_state.contacts, ev: ev) && !ev.is_reply(nil) {
|
if ev.is_textlike && should_show_event(privkey: damus_state.keypair.privkey, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: ev) && !ev.is_reply(nil)
|
||||||
|
{
|
||||||
if !damus_state.settings.multiple_events_per_pubkey && seen_pubkey.contains(ev.pubkey) {
|
if !damus_state.settings.multiple_events_per_pubkey && seen_pubkey.contains(ev.pubkey) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,9 @@ class SearchModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func filter_muted() {
|
func filter_muted() {
|
||||||
self.events.filter { should_show_event(contacts: state.contacts, ev: $0) }
|
self.events.filter {
|
||||||
|
should_show_event(privkey: state.keypair.privkey, hellthreads: state.muted_threads, contacts: state.contacts, ev: $0)
|
||||||
|
}
|
||||||
self.objectWillChange.send()
|
self.objectWillChange.send()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +57,7 @@ class SearchModel: ObservableObject {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
guard should_show_event(contacts: state.contacts, ev: ev) else {
|
guard should_show_event(privkey: state.keypair.privkey, hellthreads: state.muted_threads, contacts: state.contacts, ev: ev) else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,11 +18,11 @@ struct MutedEventView: View {
|
|||||||
self.damus_state = damus_state
|
self.damus_state = damus_state
|
||||||
self.event = event
|
self.event = event
|
||||||
self.selected = selected
|
self.selected = selected
|
||||||
self._shown = State(initialValue: should_show_event(contacts: damus_state.contacts, ev: event))
|
self._shown = State(initialValue: should_show_event(privkey: damus_state.keypair.privkey, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: event))
|
||||||
}
|
}
|
||||||
|
|
||||||
var should_mute: Bool {
|
var should_mute: Bool {
|
||||||
return !should_show_event(contacts: damus_state.contacts, ev: event)
|
return !should_show_event(privkey: damus_state.keypair.privkey, hellthreads: damus_state.muted_threads, contacts: damus_state.contacts, ev: event)
|
||||||
}
|
}
|
||||||
|
|
||||||
var MutedBox: some View {
|
var MutedBox: some View {
|
||||||
|
|||||||
Reference in New Issue
Block a user