Browse Source

EventView: remove weird embedded thing

post-button-style
William Casarin 2 years ago
parent
commit
3f3b78f9bc
  1. 39
      damus/Views/EventView.swift

39
damus/Views/EventView.swift

@ -107,7 +107,7 @@ struct BuilderEventView: View {
ProgressView().padding() ProgressView().padding()
} else { } else {
NavigationLink(destination: BuildThreadV2View(damus: damus, event_id: event!.id)) { 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) }.buttonStyle(.plain)
} }
} }
@ -128,11 +128,10 @@ struct EventView: View {
let pubkey: String let pubkey: String
let show_friend_icon: Bool let show_friend_icon: Bool
let size: EventViewKind let size: EventViewKind
let embedded: Bool
@EnvironmentObject var action_bar: ActionBarModel @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.event = event
self.highlight = highlight self.highlight = highlight
self.has_action_bar = has_action_bar self.has_action_bar = has_action_bar
@ -140,10 +139,9 @@ struct EventView: View {
self.pubkey = event.pubkey self.pubkey = event.pubkey
self.show_friend_icon = show_friend_icon self.show_friend_icon = show_friend_icon
self.size = size 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.event = event
self.highlight = .none self.highlight = .none
self.has_action_bar = false self.has_action_bar = false
@ -151,7 +149,6 @@ struct EventView: View {
self.pubkey = event.pubkey self.pubkey = event.pubkey
self.show_friend_icon = show_friend_icon self.show_friend_icon = show_friend_icon
self.size = size self.size = size
self.embedded = embedded
} }
init(damus: DamusState, event: NostrEvent, pubkey: String, show_friend_icon: Bool, size: EventViewKind = .normal, embedded: Bool = false) { 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.pubkey = pubkey
self.show_friend_icon = show_friend_icon self.show_friend_icon = show_friend_icon
self.size = size self.size = size
self.embedded = embedded
} }
var body: some View { var body: some View {
@ -209,11 +205,9 @@ struct EventView: View {
let pmodel = ProfileModel(pubkey: pubkey, damus: damus) let pmodel = ProfileModel(pubkey: pubkey, damus: damus)
let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey)) let pv = ProfileView(damus_state: damus, profile: pmodel, followers: FollowersModel(damus_state: damus, target: pubkey))
if !embedded {
NavigationLink(destination: pv) { NavigationLink(destination: pv) {
ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: highlight, profiles: damus.profiles) ProfilePicView(pubkey: pubkey, size: PFP_SIZE, highlight: highlight, profiles: damus.profiles)
} }
}
Spacer() Spacer()
} }
@ -251,33 +245,7 @@ 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) 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) .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
}
return true
}
/// MARK: - Preview
if let firstBlock = blocks.first, case .mention(let mention) = firstBlock, mention.ref.key == "e" {
BuilderEventView(damus: damus, event_id: mention.ref.id)
}
}
if !embedded {
if has_action_bar { if has_action_bar {
if size == .selected { if size == .selected {
Text("\(format_date(event.created_at))") Text("\(format_date(event.created_at))")
@ -298,7 +266,6 @@ struct EventView: View {
Divider() Divider()
.padding([.top], 4) .padding([.top], 4)
} }
}
.padding([.leading], 2) .padding([.leading], 2)
} }
.contentShape(Rectangle()) .contentShape(Rectangle())

Loading…
Cancel
Save