damus

nostr ios client
git clone git://jb55.com/damus
Log | Files | Refs | README | LICENSE

commit 3f3b78f9bc5aca3807c9420fe593a91b53c86bed
parent 2348f64dff1cf8d95feeb9431110aebb02426018
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  2 Jan 2023 18:45:30 -0800

EventView: remove weird embedded thing

Diffstat:
Mdamus/Views/EventView.swift | 71+++++++++++++++++++----------------------------------------------------
1 file changed, 19 insertions(+), 52 deletions(-)

diff --git a/damus/Views/EventView.swift b/damus/Views/EventView.swift @@ -107,7 +107,7 @@ struct BuilderEventView: View { ProgressView().padding() } else { NavigationLink(destination: BuildThreadV2View(damus: damus, event_id: event!.id)) { - EventView(damus: damus, event: event!, show_friend_icon: true, size: .small, embedded: true) + EventView(damus: damus, event: event!, show_friend_icon: true, size: .small) }.buttonStyle(.plain) } } @@ -128,11 +128,10 @@ struct EventView: View { let pubkey: String let show_friend_icon: Bool let size: EventViewKind - let embedded: Bool @EnvironmentObject var action_bar: ActionBarModel - init(event: NostrEvent, highlight: Highlight, has_action_bar: Bool, damus: DamusState, show_friend_icon: Bool, size: EventViewKind = .normal, embedded: Bool = false) { + init(event: NostrEvent, highlight: Highlight, has_action_bar: Bool, damus: DamusState, show_friend_icon: Bool, size: EventViewKind = .normal) { self.event = event self.highlight = highlight self.has_action_bar = has_action_bar @@ -140,10 +139,9 @@ struct EventView: View { self.pubkey = event.pubkey self.show_friend_icon = show_friend_icon self.size = size - self.embedded = embedded } - init(damus: DamusState, event: NostrEvent, show_friend_icon: Bool, size: EventViewKind = .normal, embedded: Bool = false) { + init(damus: DamusState, event: NostrEvent, show_friend_icon: Bool, size: EventViewKind = .normal) { self.event = event self.highlight = .none self.has_action_bar = false @@ -151,7 +149,6 @@ struct EventView: View { self.pubkey = event.pubkey self.show_friend_icon = show_friend_icon self.size = size - self.embedded = embedded } init(damus: DamusState, event: NostrEvent, pubkey: String, show_friend_icon: Bool, size: EventViewKind = .normal, embedded: Bool = false) { @@ -162,7 +159,6 @@ struct EventView: View { self.pubkey = pubkey self.show_friend_icon = show_friend_icon self.size = size - self.embedded = embedded } var body: some View { @@ -209,10 +205,8 @@ struct EventView: View { let pmodel = ProfileModel(pubkey: pubkey, damus: damus) let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey)) - if !embedded { - NavigationLink(destination: pv) { - ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: highlight, profiles: damus.profiles) - } + NavigationLink(destination: pv) { + ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: highlight, profiles: damus.profiles) } Spacer() @@ -251,53 +245,26 @@ struct EventView: View { NoteContentView(privkey: damus.keypair.privkey, event: event, profiles: damus.profiles, previews: damus.previews, show_images: should_show_img, artifacts: .just_content(content), size: self.size) .frame(maxWidth: .infinity, alignment: .leading) - .allowsHitTesting(!embedded) - if !embedded { - let blocks = event.blocks(damus.keypair.privkey).filter { block in - guard case .mention(let mention) = block else { - return false - } - - guard case .event = mention.type else { - return false - } - - if mention.ref.key != "e" { - return false - } - + if has_action_bar { + if size == .selected { + Text("\(format_date(event.created_at))") + .padding(.top, 10) + .font(.footnote) + .foregroundColor(.gray) - return true + Divider() + .padding([.bottom], 4) + } else { + Rectangle().frame(height: 2).opacity(0) } - /// MARK: - Preview - if let firstBlock = blocks.first, case .mention(let mention) = firstBlock, mention.ref.key == "e" { - BuilderEventView(damus: damus, event_id: mention.ref.id) - } + let bar = make_actionbar_model(ev: event, damus: damus) + EventActionBar(damus_state: damus, event: event, bar: bar) } - if !embedded { - if has_action_bar { - if size == .selected { - Text("\(format_date(event.created_at))") - .padding(.top, 10) - .font(.footnote) - .foregroundColor(.gray) - - Divider() - .padding([.bottom], 4) - } else { - Rectangle().frame(height: 2).opacity(0) - } - - let bar = make_actionbar_model(ev: event, damus: damus) - EventActionBar(damus_state: damus, event: event, bar: bar) - } - - Divider() - .padding([.top], 4) - } + Divider() + .padding([.top], 4) } .padding([.leading], 2) }