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.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)
|
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 {
|
var note_content: some View {
|
||||||
if event.known_kind == .longform {
|
|
||||||
let longform = LongformEvent.parse(from: event)
|
|
||||||
|
|
||||||
Text(longform.title ?? "Untitled")
|
|
||||||
.font(.title)
|
|
||||||
.padding(.horizontal)
|
|
||||||
}
|
|
||||||
|
|
||||||
NoteContentView(damus_state: damus_state, event: event, show_images: should_show_img, size: size, options: options)
|
NoteContentView(damus_state: damus_state, event: event, show_images: should_show_img, size: size, options: options)
|
||||||
.frame(maxWidth: .infinity, alignment: .leading)
|
.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 {
|
struct EventBody_Previews: PreviewProvider {
|
||||||
|
|||||||
@@ -7,12 +7,20 @@
|
|||||||
|
|
||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct LongformPreview: View {
|
struct LongformPreviewBody: View {
|
||||||
let state: DamusState
|
let state: DamusState
|
||||||
let event: LongformEvent
|
let event: LongformEvent
|
||||||
let options: EventViewOptions
|
let options: EventViewOptions
|
||||||
@ObservedObject var artifacts: NoteArtifactsModel
|
@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) {
|
init(state: DamusState, ev: NostrEvent, options: EventViewOptions) {
|
||||||
self.state = state
|
self.state = state
|
||||||
self.event = LongformEvent.parse(from: ev)
|
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)
|
self._artifacts = ObservedObject(wrappedValue: state.events.get_cache_data(ev.id).artifacts_model)
|
||||||
}
|
}
|
||||||
|
|
||||||
func Words(_ words: Int) -> Text {
|
func Words(_ words: Int) -> Text {
|
||||||
Text(verbatim: words.description) + Text(verbatim: " ") + Text("Words")
|
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 {
|
var Main: some View {
|
||||||
VStack(alignment: .leading, spacing: 10) {
|
VStack(alignment: .leading, spacing: 10) {
|
||||||
Text(event.title ?? "Untitled")
|
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 {
|
var body: some View {
|
||||||
EventShell(state: state, event: event.event, options: options.union(.no_mentions)) {
|
EventShell(state: state, event: event.event, options: options) {
|
||||||
|
LongformPreviewBody(state: state, ev: event, options: options)
|
||||||
if options.contains(.wide) {
|
|
||||||
Main.padding(.horizontal)
|
|
||||||
} else {
|
|
||||||
Main
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user