reposts: add links to repost listing in timeline

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2025-02-12 15:43:19 -08:00
parent bed4e00b53
commit 4741c2a3e8

View File

@@ -11,6 +11,14 @@ struct Reposted: View {
let damus: DamusState let damus: DamusState
let pubkey: Pubkey let pubkey: Pubkey
let target: NoteId 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 { var body: some View {
HStack(alignment: .center) { HStack(alignment: .center) {
@@ -18,15 +26,24 @@ struct Reposted: View {
.foregroundColor(Color.gray) .foregroundColor(Color.gray)
ProfileName(pubkey: pubkey, damus: damus, show_nip5_domain: false) ProfileName(pubkey: pubkey, damus: damus, show_nip5_domain: false)
.foregroundColor(Color.gray) .foregroundColor(Color.gray)
let other_reposts = (damus.boosts.counts[target] ?? 0) - 1 NavigationLink(value: Route.Reposts(reposts: .reposts(state: damus, target: target))) {
if other_reposts > 0 { let other_reposts = reposts - 1
Text(" and \(other_reposts) others reposted", comment: "Text indicating that the note was reposted (i.e. re-shared) by multiple people") if other_reposts > 0 {
.foregroundColor(Color.gray) Text(" and \(other_reposts) others reposted", comment: "Text indicating that the note was reposted (i.e. re-shared) by multiple people")
} else { .foregroundColor(Color.gray)
Text("reposted", comment: "Text indicating that the note was reposted (i.e. re-shared).") } else {
.foregroundColor(Color.gray) 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
}
})
} }
} }