Ensure stats get updated in realtime on action bars
Changelog-Fixed: Ensure stats get updated in realtime on action bars
This commit is contained in:
@@ -230,6 +230,7 @@ class HomeModel: ObservableObject {
|
|||||||
case .success(let n):
|
case .success(let n):
|
||||||
let boosted = Counted(event: ev, id: e, total: n)
|
let boosted = Counted(event: ev, id: e, total: n)
|
||||||
notify(.boosted, boosted)
|
notify(.boosted, boosted)
|
||||||
|
notify(.update_stats, e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +248,7 @@ class HomeModel: ObservableObject {
|
|||||||
case .success(let n):
|
case .success(let n):
|
||||||
let liked = Counted(event: ev, id: e.ref_id, total: n)
|
let liked = Counted(event: ev, id: e.ref_id, total: n)
|
||||||
notify(.liked, liked)
|
notify(.liked, liked)
|
||||||
|
notify(.update_stats, e.ref_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,8 +98,8 @@ extension Notification.Name {
|
|||||||
static var deleted_account: Notification.Name {
|
static var deleted_account: Notification.Name {
|
||||||
return Notification.Name("deleted_account")
|
return Notification.Name("deleted_account")
|
||||||
}
|
}
|
||||||
static var new_zap: Notification.Name {
|
static var update_stats: Notification.Name {
|
||||||
return Notification.Name("new_zap")
|
return Notification.Name("update_stats")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class Zaps {
|
|||||||
event_counts[id] = event_counts[id]! + 1
|
event_counts[id] = event_counts[id]! + 1
|
||||||
event_totals[id] = event_totals[id]! + zap.invoice.amount
|
event_totals[id] = event_totals[id]! + zap.invoice.amount
|
||||||
|
|
||||||
notify(.new_zap, zap)
|
notify(.update_stats, zap.target.id)
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,15 +111,10 @@ struct EventActionBar: View {
|
|||||||
} message: {
|
} message: {
|
||||||
Text("Are you sure you want to repost this?", comment: "Alert message to ask if user wants to repost a post.")
|
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
|
.onReceive(handle_notify(.update_stats)) { n in
|
||||||
let zap = n.object as! Zap
|
let target = n.object as! String
|
||||||
guard case .note(let note_target) = zap.target else {
|
guard target == self.event.id else { return }
|
||||||
return
|
self.bar.update(damus: self.damus_state, evid: target)
|
||||||
}
|
|
||||||
guard note_target.note_id == self.event.id else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
self.bar.update(damus: self.damus_state, evid: self.event.id)
|
|
||||||
}
|
}
|
||||||
.onReceive(handle_notify(.liked)) { n in
|
.onReceive(handle_notify(.liked)) { n in
|
||||||
let liked = n.object as! Counted
|
let liked = n.object as! Counted
|
||||||
|
|||||||
@@ -54,15 +54,10 @@ struct SelectedEventView: View {
|
|||||||
Divider()
|
Divider()
|
||||||
.padding([.top], 4)
|
.padding([.top], 4)
|
||||||
}
|
}
|
||||||
.onReceive(handle_notify(.new_zap)) { n in
|
.onReceive(handle_notify(.update_stats)) { n in
|
||||||
let zap = n.object as! Zap
|
let target = n.object as! String
|
||||||
guard case .note(let note_target) = zap.target else {
|
guard target == self.event.id else { return }
|
||||||
return
|
self.bar.update(damus: self.damus, evid: target)
|
||||||
}
|
|
||||||
guard note_target.note_id == self.event.id else {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
self.bar.update(damus: self.damus, evid: self.event.id)
|
|
||||||
}
|
}
|
||||||
.padding([.leading], 2)
|
.padding([.leading], 2)
|
||||||
.event_context_menu(event, keypair: damus.keypair, target_pubkey: event.pubkey)
|
.event_context_menu(event, keypair: damus.keypair, target_pubkey: event.pubkey)
|
||||||
|
|||||||
Reference in New Issue
Block a user