Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-conditional.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
default: patch
---

Fix conditional memo in reply renderer leading to crashes.
31 changes: 16 additions & 15 deletions src/app/components/message/Reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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, ' ')
Expand All @@ -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,
Expand Down
Loading