notes: count words in notes during artifact parsing
This commit is contained in:
@@ -1170,7 +1170,7 @@ func process_local_notification(damus_state: DamusState, event ev: NostrEvent) {
|
||||
}
|
||||
|
||||
if type == .text && damus_state.settings.mention_notification {
|
||||
let blocks = ev.blocks(damus_state.keypair.privkey)
|
||||
let blocks = ev.blocks(damus_state.keypair.privkey).blocks
|
||||
for case .mention(let mention) in blocks where mention.ref.ref_id == damus_state.keypair.pubkey {
|
||||
let content = NSAttributedString(render_note_content(ev: ev, profiles: damus_state.profiles, privkey: damus_state.keypair.privkey).content.attributed).string
|
||||
|
||||
|
||||
@@ -150,7 +150,12 @@ func render_blocks(blocks: [Block]) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
func parse_mentions(content: String, tags: [[String]]) -> [Block] {
|
||||
struct Blocks {
|
||||
let words: Int
|
||||
let blocks: [Block]
|
||||
}
|
||||
|
||||
func parse_mentions(content: String, tags: [[String]]) -> Blocks {
|
||||
var out: [Block] = []
|
||||
|
||||
var bs = note_blocks()
|
||||
@@ -174,9 +179,10 @@ func parse_mentions(content: String, tags: [[String]]) -> [Block] {
|
||||
i += 1
|
||||
}
|
||||
|
||||
let words = Int(bs.words)
|
||||
blocks_free(&bs)
|
||||
|
||||
return out
|
||||
return Blocks(words: words, blocks: out)
|
||||
}
|
||||
|
||||
func strblock_to_string(_ s: str_block_t) -> String? {
|
||||
|
||||
Reference in New Issue
Block a user