fix conditional memo in reply renderer

This commit is contained in:
7w1 committed 2026-03-21 00:43:11 -05:00
1 parent 920d35fe4b
commit 1f561c730d
2 files changed
+21 -15

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
---
default: patch
---
Fix conditional memo in reply renderer leading to crashes.
+16 -15
View File
@@ -132,6 +132,22 @@ export const Reply = as<'div', ReplyProps>(
let bodyJSX: ReactNode = fallbackBody;
let image: IconSrc | undefined;
const replyLinkifyOpts = useMemo(
() => ({
...LINKIFY_OPTS,
render: factoryRenderLinkifyWithMention((href) =>
renderMatrixMention(
mx,
room.roomId,
href,
makeMentionCustomProps(mentionClickHandler),
nicknames
)
),
}),
[mx, room.roomId, mentionClickHandler, nicknames]
);
if (format === 'org.matrix.custom.html' && formattedBody) {
const strippedHtml = trimReplyFromFormattedBody(formattedBody)
.replaceAll(/<br\s*\/?>/gi, ' ')
@@ -140,21 +156,6 @@ export const Reply = as<'div', ReplyProps>(
.replaceAll(/<\/li>\s*<li[^>]*>/gi, ' ')
.replaceAll(/<\/?(ul|ol|li|blockquote|h[1-6]|pre|div)[^>]*>/gi, '')
.replaceAll(/(?:\r\n|\r|\n)/g, ' ');
const replyLinkifyOpts = useMemo(
() => ({
...LINKIFY_OPTS,
render: factoryRenderLinkifyWithMention((href) =>
renderMatrixMention(
mx,
room.roomId,
href,
makeMentionCustomProps(mentionClickHandler),
nicknames
)
),
}),
[mx, room.roomId, mentionClickHandler, nicknames]
);
const parserOpts = getReactCustomHtmlParser(mx, room.roomId, {
linkifyOpts: replyLinkifyOpts,
useAuthentication,