Handle message cleanup

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