[🐴] Post embeds polish (#4339)

* Handle message cleanup

* Handle last message in chat list

* Memoize lastMessage
This commit is contained in:
Eric Bailey 2024-06-03 20:07:01 -05:00 committed by GitHub
parent da96fb1ef5
commit de93e8de74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 30 deletions

View file

@ -312,25 +312,19 @@ export function MessagesList({
})
if (postLinkFacet) {
// remove the post link from the text
rt.delete(
postLinkFacet.index.byteStart,
postLinkFacet.index.byteEnd,
)
const isAtStart = postLinkFacet.index.byteStart === 0
const isAtEnd =
postLinkFacet.index.byteEnd === rt.unicodeText.graphemeLength
// re-trim the text, now that we've removed the post link
//
// if the post link is at the start of the text, we don't want to leave a leading space
// so trim on both sides
if (postLinkFacet.index.byteStart === 0) {
rt = new RichText({text: rt.text.trim()}, {cleanNewlines: true})
} else {
// otherwise just trim the end
rt = new RichText(
{text: rt.text.trimEnd()},
{cleanNewlines: true},
// remove the post link from the text
if (isAtStart || isAtEnd) {
rt.delete(
postLinkFacet.index.byteStart,
postLinkFacet.index.byteEnd,
)
}
rt = new RichText({text: rt.text.trim()}, {cleanNewlines: true})
}
}
} catch (error) {