Skip to content

Commit 1f561c7

Browse files
committed
fix conditional memo in reply renderer
1 parent 920d35f commit 1f561c7

2 files changed

Lines changed: 21 additions & 15 deletions

File tree

.changeset/fix-conditional.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
default: patch
3+
---
4+
5+
Fix conditional memo in reply renderer leading to crashes.

src/app/components/message/Reply.tsx

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,22 @@ export const Reply = as<'div', ReplyProps>(
132132
let bodyJSX: ReactNode = fallbackBody;
133133
let image: IconSrc | undefined;
134134

135+
const replyLinkifyOpts = useMemo(
136+
() => ({
137+
...LINKIFY_OPTS,
138+
render: factoryRenderLinkifyWithMention((href) =>
139+
renderMatrixMention(
140+
mx,
141+
room.roomId,
142+
href,
143+
makeMentionCustomProps(mentionClickHandler),
144+
nicknames
145+
)
146+
),
147+
}),
148+
[mx, room.roomId, mentionClickHandler, nicknames]
149+
);
150+
135151
if (format === 'org.matrix.custom.html' && formattedBody) {
136152
const strippedHtml = trimReplyFromFormattedBody(formattedBody)
137153
.replaceAll(/<br\s*\/?>/gi, ' ')
@@ -140,21 +156,6 @@ export const Reply = as<'div', ReplyProps>(
140156
.replaceAll(/<\/li>\s*<li[^>]*>/gi, ' ')
141157
.replaceAll(/<\/?(ul|ol|li|blockquote|h[1-6]|pre|div)[^>]*>/gi, '')
142158
.replaceAll(/(?:\r\n|\r|\n)/g, ' ');
143-
const replyLinkifyOpts = useMemo(
144-
() => ({
145-
...LINKIFY_OPTS,
146-
render: factoryRenderLinkifyWithMention((href) =>
147-
renderMatrixMention(
148-
mx,
149-
room.roomId,
150-
href,
151-
makeMentionCustomProps(mentionClickHandler),
152-
nicknames
153-
)
154-
),
155-
}),
156-
[mx, room.roomId, mentionClickHandler, nicknames]
157-
);
158159
const parserOpts = getReactCustomHtmlParser(mx, room.roomId, {
159160
linkifyOpts: replyLinkifyOpts,
160161
useAuthentication,

0 commit comments

Comments
 (0)