Only show longform preview in notifications
Changelog-Fixed: Show longform previews in notifications instead of the entire post
This commit is contained in:
@@ -21,19 +21,24 @@ struct EventBody: View {
|
||||
self.options = options
|
||||
self.should_show_img = should_show_img ?? should_show_images(settings: damus_state.settings, contacts: damus_state.contacts, ev: event, our_pubkey: damus_state.pubkey)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if event.known_kind == .longform {
|
||||
let longform = LongformEvent.parse(from: event)
|
||||
|
||||
Text(longform.title ?? "Untitled")
|
||||
.font(.title)
|
||||
.padding(.horizontal)
|
||||
}
|
||||
|
||||
|
||||
var note_content: some View {
|
||||
NoteContentView(damus_state: damus_state, event: event, show_images: should_show_img, size: size, options: options)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
if event.known_kind == .longform {
|
||||
LongformPreviewBody(state: damus_state, ev: event, options: options)
|
||||
|
||||
// truncated longform bodies are just the preview
|
||||
if !options.contains(.truncate_content) {
|
||||
note_content
|
||||
}
|
||||
} else {
|
||||
note_content
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct EventBody_Previews: PreviewProvider {
|
||||
|
||||
@@ -7,12 +7,20 @@
|
||||
|
||||
import SwiftUI
|
||||
|
||||
struct LongformPreview: View {
|
||||
struct LongformPreviewBody: View {
|
||||
let state: DamusState
|
||||
let event: LongformEvent
|
||||
let options: EventViewOptions
|
||||
@ObservedObject var artifacts: NoteArtifactsModel
|
||||
|
||||
|
||||
init(state: DamusState, ev: LongformEvent, options: EventViewOptions) {
|
||||
self.state = state
|
||||
self.event = ev
|
||||
self.options = options
|
||||
|
||||
self._artifacts = ObservedObject(wrappedValue: state.events.get_cache_data(ev.event.id).artifacts_model)
|
||||
}
|
||||
|
||||
init(state: DamusState, ev: NostrEvent, options: EventViewOptions) {
|
||||
self.state = state
|
||||
self.event = LongformEvent.parse(from: ev)
|
||||
@@ -20,11 +28,21 @@ struct LongformPreview: View {
|
||||
|
||||
self._artifacts = ObservedObject(wrappedValue: state.events.get_cache_data(ev.id).artifacts_model)
|
||||
}
|
||||
|
||||
|
||||
func Words(_ words: Int) -> Text {
|
||||
Text(verbatim: words.description) + Text(verbatim: " ") + Text("Words")
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
Group {
|
||||
if options.contains(.wide) {
|
||||
Main.padding(.horizontal)
|
||||
} else {
|
||||
Main
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var Main: some View {
|
||||
VStack(alignment: .leading, spacing: 10) {
|
||||
Text(event.title ?? "Untitled")
|
||||
@@ -40,15 +58,22 @@ struct LongformPreview: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct LongformPreview: View {
|
||||
let state: DamusState
|
||||
let event: LongformEvent
|
||||
let options: EventViewOptions
|
||||
|
||||
init(state: DamusState, ev: NostrEvent, options: EventViewOptions) {
|
||||
self.state = state
|
||||
self.event = LongformEvent.parse(from: ev)
|
||||
self.options = options.union(.no_mentions)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
EventShell(state: state, event: event.event, options: options.union(.no_mentions)) {
|
||||
|
||||
if options.contains(.wide) {
|
||||
Main.padding(.horizontal)
|
||||
} else {
|
||||
Main
|
||||
}
|
||||
EventShell(state: state, event: event.event, options: options) {
|
||||
LongformPreviewBody(state: state, ev: event, options: options)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user