Browse Source

Don't Badge DMs if Sent By You

Closes: #176
Changelog-Fixed: Don't badge DMs if sent by you
post-button-style
Joel Klabo 2 years ago
committed by William Casarin
parent
commit
79ea4da2d2
  1. 6
      damus/Models/HomeModel.swift

6
damus/Models/HomeModel.swift

@ -338,14 +338,16 @@ class HomeModel: ObservableObject {
return m[kind] return m[kind]
} }
func handle_last_event(ev: NostrEvent, timeline: Timeline) { func handle_last_event(ev: NostrEvent, timeline: Timeline, shouldNotify: Bool = true) {
let last_ev = get_last_event(timeline) let last_ev = get_last_event(timeline)
if last_ev == nil || last_ev!.created_at < ev.created_at { if last_ev == nil || last_ev!.created_at < ev.created_at {
save_last_event(ev, timeline: timeline) save_last_event(ev, timeline: timeline)
if shouldNotify {
new_events = NewEventsBits(prev: new_events, setting: timeline) new_events = NewEventsBits(prev: new_events, setting: timeline)
} }
} }
}
func handle_notification(ev: NostrEvent) { func handle_notification(ev: NostrEvent) {
if !insert_uniq_sorted_event(events: &notifications, new_ev: ev, cmp: { $0.created_at > $1.created_at }) { if !insert_uniq_sorted_event(events: &notifications, new_ev: ev, cmp: { $0.created_at > $1.created_at }) {
@ -415,7 +417,7 @@ class HomeModel: ObservableObject {
} }
if inserted { if inserted {
handle_last_event(ev: ev, timeline: .dms) handle_last_event(ev: ev, timeline: .dms, shouldNotify: !ours)
dms.dms = dms.dms.sorted { a, b in dms.dms = dms.dms.sorted { a, b in
if a.1.events.count > 0 && b.1.events.count > 0 { if a.1.events.count > 0 && b.1.events.count > 0 {

Loading…
Cancel
Save