parse hashtags

Signed-off-by: William Casarin <jb55@jb55.com>
This commit is contained in:
William Casarin
2022-05-08 20:34:57 -07:00
parent 812abba8d4
commit cf7cba09bd
6 changed files with 100 additions and 24 deletions

View File

@@ -15,6 +15,8 @@ func render_note_content(ev: NostrEvent, profiles: Profiles) -> String {
return str + mention_str(m, profiles: profiles)
case .text(let txt):
return str + txt
case .hashtag(let htag):
return str + hashtag_str(htag)
}
}
}
@@ -49,14 +51,18 @@ struct NoteContentView: View {
if m.type == .pubkey && m.ref.ref_id == profile.pubkey {
content = render_note_content(ev: event, profiles: profiles)
}
case .text:
return
case .text: return
case .hashtag: return
}
}
}
}
}
func hashtag_str(_ htag: String) -> String {
return "[#\(htag)](nostr:hashtag:\(htag))"
}
func mention_str(_ m: Mention, profiles: Profiles) -> String {
switch m.type {
case .pubkey:

View File

@@ -22,9 +22,9 @@ struct ProfileView: View {
@EnvironmentObject var profiles: Profiles
var TopSection: some View {
VStack{
VStack(alignment: .leading) {
let data = profiles.lookup(id: profile.pubkey)
HStack {
HStack(alignment: .top) {
ProfilePicView(pubkey: profile.pubkey, size: PFP_SIZE!, highlight: .custom(Color.black, 2), image_cache: damus.image_cache)
.environmentObject(profiles)