@@ -113,10 +113,11 @@ struct ChatView: View {
|
||||
NoteContentView(event: event, profiles: damus.profiles, content: event.content)
|
||||
|
||||
if is_active || next_ev == nil || next_ev!.pubkey != event.pubkey {
|
||||
let bar = make_actionbar_model(ev: event, like_counter: damus.likes, boost_counter: damus.boosts)
|
||||
EventActionBar(event: event,
|
||||
our_pubkey: damus.pubkey,
|
||||
profiles: damus.profiles,
|
||||
bar: make_actionbar_model(ev: event, counter: damus.likes)
|
||||
bar: bar
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ struct EventActionBar: View {
|
||||
HStack(alignment: .bottom) {
|
||||
Text("\(bar.likes > 0 ? "\(bar.likes)" : "")")
|
||||
.font(.footnote)
|
||||
.foregroundColor(Color.gray)
|
||||
.foregroundColor(bar.liked ? Color.red : Color.gray)
|
||||
|
||||
EventActionButton(img: bar.liked ? "heart.fill" : "heart", col: bar.liked ? Color.red : nil) {
|
||||
if bar.liked {
|
||||
@@ -54,23 +54,29 @@ struct EventActionBar: View {
|
||||
}
|
||||
.padding([.trailing], 40)
|
||||
|
||||
EventActionButton(img: "arrow.2.squarepath", col: bar.boosted ? Color.green : nil) {
|
||||
if bar.boosted {
|
||||
notify(.delete, bar.our_boost)
|
||||
} else {
|
||||
notify(.boost, event)
|
||||
HStack(alignment: .bottom) {
|
||||
Text("\(bar.boosts > 0 ? "\(bar.boosts)" : "")")
|
||||
.font(.footnote)
|
||||
.foregroundColor(bar.boosted ? Color.green : Color.gray)
|
||||
|
||||
EventActionButton(img: "arrow.2.squarepath", col: bar.boosted ? Color.green : nil) {
|
||||
if bar.boosted {
|
||||
notify(.delete, bar.our_boost)
|
||||
} else {
|
||||
notify(.boost, event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
.onReceive(handle_notify(.liked)) { n in
|
||||
let liked = n.object as! Liked
|
||||
let liked = n.object as! Counted
|
||||
if liked.id != event.id {
|
||||
return
|
||||
}
|
||||
self.bar.likes = liked.total
|
||||
if liked.like.pubkey == our_pubkey {
|
||||
self.bar.our_like = liked.like
|
||||
if liked.event.pubkey == our_pubkey {
|
||||
self.bar.our_like = liked.event
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,8 +45,28 @@ struct EventView: View {
|
||||
@EnvironmentObject var action_bar: ActionBarModel
|
||||
|
||||
var body: some View {
|
||||
let profile = damus.profiles.lookup(id: event.pubkey)
|
||||
HStack {
|
||||
return Group {
|
||||
if event.known_kind == .boost, let inner_ev = event.inner_event {
|
||||
VStack(alignment: .leading) {
|
||||
HStack {
|
||||
Label("", systemImage: "arrow.2.squarepath")
|
||||
.foregroundColor(Color.gray)
|
||||
ProfileName(pubkey: event.pubkey, profile: damus.profiles.lookup(id: event.pubkey))
|
||||
.foregroundColor(Color.gray)
|
||||
Text(" Boosted")
|
||||
.foregroundColor(Color.gray)
|
||||
}
|
||||
TextEvent(inner_ev)
|
||||
}
|
||||
} else {
|
||||
TextEvent(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TextEvent(_ event: NostrEvent) -> some View {
|
||||
return HStack {
|
||||
let profile = damus.profiles.lookup(id: event.pubkey)
|
||||
VStack {
|
||||
let pv = ProfileView(damus: damus, profile: ProfileModel(pubkey: event.pubkey, damus: damus))
|
||||
|
||||
@@ -79,7 +99,8 @@ struct EventView: View {
|
||||
Spacer()
|
||||
|
||||
if has_action_bar {
|
||||
EventActionBar(event: event, our_pubkey: damus.pubkey, profiles: damus.profiles, bar: make_actionbar_model(ev: event, counter: damus.likes))
|
||||
let bar = make_actionbar_model(ev: event, like_counter: damus.likes, boost_counter: damus.boosts)
|
||||
EventActionBar(event: event, our_pubkey: damus.pubkey, profiles: damus.profiles, bar: bar)
|
||||
}
|
||||
|
||||
Divider()
|
||||
@@ -159,10 +180,11 @@ func reply_others_desc(n: Int, n_pubkeys: Int) -> String {
|
||||
|
||||
|
||||
|
||||
func make_actionbar_model(ev: NostrEvent, counter: EventCounter) -> ActionBarModel {
|
||||
let likes = counter.counts[ev.id]
|
||||
let our_like = counter.our_events[ev.id]
|
||||
let our_boost: NostrEvent? = nil
|
||||
func make_actionbar_model(ev: NostrEvent, like_counter: EventCounter, boost_counter: EventCounter) -> ActionBarModel {
|
||||
let likes = like_counter.counts[ev.id]
|
||||
let boosts = boost_counter.counts[ev.id]
|
||||
let our_like = like_counter.our_events[ev.id]
|
||||
let our_boost = boost_counter.our_events[ev.id]
|
||||
|
||||
return ActionBarModel(likes: likes ?? 0, our_like: our_like, our_boost: our_boost)
|
||||
return ActionBarModel(likes: likes ?? 0, boosts: boosts ?? 0, our_like: our_like, our_boost: our_boost)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user