commit 4741c2a3e8d34e72b99d8475399fda18242aceeb
parent bed4e00b538d4597e2c976ea590f08626136afc4
Author: William Casarin <jb55@jb55.com>
Date: Wed, 12 Feb 2025 15:43:19 -0800
reposts: add links to repost listing in timeline
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 24 insertions(+), 7 deletions(-)
diff --git a/damus/Components/Reposted.swift b/damus/Components/Reposted.swift
@@ -11,6 +11,14 @@ struct Reposted: View {
let damus: DamusState
let pubkey: Pubkey
let target: NoteId
+ @State var reposts: Int
+
+ init(damus: DamusState, pubkey: Pubkey, target: NoteId) {
+ self.damus = damus
+ self.pubkey = pubkey
+ self.target = target
+ self.reposts = damus.boosts.counts[target] ?? 1
+ }
var body: some View {
HStack(alignment: .center) {
@@ -18,15 +26,24 @@ struct Reposted: View {
.foregroundColor(Color.gray)
ProfileName(pubkey: pubkey, damus: damus, show_nip5_domain: false)
.foregroundColor(Color.gray)
- let other_reposts = (damus.boosts.counts[target] ?? 0) - 1
- if other_reposts > 0 {
- Text(" and \(other_reposts) others reposted", comment: "Text indicating that the note was reposted (i.e. re-shared) by multiple people")
- .foregroundColor(Color.gray)
- } else {
- Text("reposted", comment: "Text indicating that the note was reposted (i.e. re-shared).")
- .foregroundColor(Color.gray)
+ NavigationLink(value: Route.Reposts(reposts: .reposts(state: damus, target: target))) {
+ let other_reposts = reposts - 1
+ if other_reposts > 0 {
+ Text(" and \(other_reposts) others reposted", comment: "Text indicating that the note was reposted (i.e. re-shared) by multiple people")
+ .foregroundColor(Color.gray)
+ } else {
+ Text("reposted", comment: "Text indicating that the note was reposted (i.e. re-shared).")
+ .foregroundColor(Color.gray)
+ }
}
}
+ .onReceive(handle_notify(.update_stats), perform: { note_id in
+ guard note_id == target else { return }
+ let repost_count = damus.boosts.counts[target]
+ if let repost_count, reposts != repost_count {
+ reposts = repost_count
+ }
+ })
}
}