diff --git a/damus/Models/HomeModel.swift b/damus/Models/HomeModel.swift index 63e85976..f0792e6c 100644 --- a/damus/Models/HomeModel.swift +++ b/damus/Models/HomeModel.swift @@ -230,6 +230,7 @@ class HomeModel: ObservableObject { case .success(let n): let boosted = Counted(event: ev, id: e, total: n) notify(.boosted, boosted) + notify(.update_stats, e) } } @@ -247,6 +248,7 @@ class HomeModel: ObservableObject { case .success(let n): let liked = Counted(event: ev, id: e.ref_id, total: n) notify(.liked, liked) + notify(.update_stats, e.ref_id) } } diff --git a/damus/Util/Notifications.swift b/damus/Util/Notifications.swift index ae8f0264..73706a40 100644 --- a/damus/Util/Notifications.swift +++ b/damus/Util/Notifications.swift @@ -98,8 +98,8 @@ extension Notification.Name { static var deleted_account: Notification.Name { return Notification.Name("deleted_account") } - static var new_zap: Notification.Name { - return Notification.Name("new_zap") + static var update_stats: Notification.Name { + return Notification.Name("update_stats") } } diff --git a/damus/Util/Zaps.swift b/damus/Util/Zaps.swift index 15dafd52..e5e15fea 100644 --- a/damus/Util/Zaps.swift +++ b/damus/Util/Zaps.swift @@ -60,7 +60,7 @@ class Zaps { event_counts[id] = event_counts[id]! + 1 event_totals[id] = event_totals[id]! + zap.invoice.amount - notify(.new_zap, zap) + notify(.update_stats, zap.target.id) return } diff --git a/damus/Views/ActionBar/EventActionBar.swift b/damus/Views/ActionBar/EventActionBar.swift index b8c9a4e3..1852b918 100644 --- a/damus/Views/ActionBar/EventActionBar.swift +++ b/damus/Views/ActionBar/EventActionBar.swift @@ -111,15 +111,10 @@ struct EventActionBar: View { } message: { Text("Are you sure you want to repost this?", comment: "Alert message to ask if user wants to repost a post.") } - .onReceive(handle_notify(.new_zap)) { n in - let zap = n.object as! Zap - guard case .note(let note_target) = zap.target else { - return - } - guard note_target.note_id == self.event.id else { - return - } - self.bar.update(damus: self.damus_state, evid: self.event.id) + .onReceive(handle_notify(.update_stats)) { n in + let target = n.object as! String + guard target == self.event.id else { return } + self.bar.update(damus: self.damus_state, evid: target) } .onReceive(handle_notify(.liked)) { n in let liked = n.object as! Counted diff --git a/damus/Views/Events/SelectedEventView.swift b/damus/Views/Events/SelectedEventView.swift index a897b799..a4cf4648 100644 --- a/damus/Views/Events/SelectedEventView.swift +++ b/damus/Views/Events/SelectedEventView.swift @@ -54,15 +54,10 @@ struct SelectedEventView: View { Divider() .padding([.top], 4) } - .onReceive(handle_notify(.new_zap)) { n in - let zap = n.object as! Zap - guard case .note(let note_target) = zap.target else { - return - } - guard note_target.note_id == self.event.id else { - return - } - self.bar.update(damus: self.damus, evid: self.event.id) + .onReceive(handle_notify(.update_stats)) { n in + let target = n.object as! String + guard target == self.event.id else { return } + self.bar.update(damus: self.damus, evid: target) } .padding([.leading], 2) .event_context_menu(event, keypair: damus.keypair, target_pubkey: event.pubkey)