commit 159d0fa2b59103a774c9b1acf4146bc01474245f
parent 61fddf800e1064626b8ecf6edf955a7e3e471a94
Author: William Casarin <jb55@jb55.com>
Date: Sat, 25 Mar 2023 07:54:04 -0600
Don't render @note link if there is only one
Diffstat:
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/damus/Models/Mentions.swift b/damus/Models/Mentions.swift
@@ -94,6 +94,14 @@ enum Block {
return nil
}
+ var is_note_mention: Bool {
+ guard case .mention(let mention) = self else {
+ return false
+ }
+
+ return mention.type == .event
+ }
+
var is_mention: Bool {
if case .mention = self {
return true
diff --git a/damus/Views/NoteContentView.swift b/damus/Views/NoteContentView.swift
@@ -204,6 +204,7 @@ struct NoteArtifacts {
func render_note_content(ev: NostrEvent, profiles: Profiles, privkey: String?) -> NoteArtifacts {
let blocks = ev.blocks(privkey)
+
return render_blocks(blocks: blocks, profiles: profiles, privkey: privkey)
}
@@ -211,9 +212,17 @@ func render_blocks(blocks: [Block], profiles: Profiles, privkey: String?) -> Not
var invoices: [Invoice] = []
var img_urls: [URL] = []
var link_urls: [URL] = []
+
+ let one_note_ref = blocks
+ .filter({ $0.is_note_mention })
+ .count == 1
+
let txt: AttributedString = blocks.reduce("") { str, block in
switch block {
case .mention(let m):
+ if m.type == .event && one_note_ref {
+ return str
+ }
return str + mention_str(m, profiles: profiles)
case .text(let txt):
return str + AttributedString(stringLiteral: txt)
diff --git a/damus/Views/Timeline/InnerTimelineView.swift b/damus/Views/Timeline/InnerTimelineView.swift
@@ -42,10 +42,10 @@ struct InnerTimelineView: View {
nav_target = ev.inner_event ?? ev
navigating = true
}
- .padding(.top, 5)
+ .padding(.top, 7)
Divider()
- .padding([.top], 5)
+ .padding([.top], 7)
}
}
}