From 8b3ff4f8b1c0812f19243e9f89fdd9a938989f70 Mon Sep 17 00:00:00 2001 From: Echo Date: Mon, 20 Oct 2025 16:52:27 +0200 Subject: [PATCH] [Glitch] Emoji: Fix unneeded re-renders when StatusContent changes Port 6e2973aa2d3dc9466f2cc9b352e0eb2b260bf463 to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/status_content.jsx | 4 ++-- .../components/embedded_status_content.tsx | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/javascript/flavours/glitch/components/status_content.jsx b/app/javascript/flavours/glitch/components/status_content.jsx index 6f7b9e0fdf..41a44ce404 100644 --- a/app/javascript/flavours/glitch/components/status_content.jsx +++ b/app/javascript/flavours/glitch/components/status_content.jsx @@ -366,7 +366,7 @@ class StatusContent extends PureComponent { lang={language} htmlString={content} extraEmojis={status.get('emojis')} - onElement={this.handleElement.bind(this)} + onElement={this.handleElement} /> {poll} @@ -384,7 +384,7 @@ class StatusContent extends PureComponent { lang={language} htmlString={content} extraEmojis={status.get('emojis')} - onElement={this.handleElement.bind(this)} + onElement={this.handleElement} /> {poll} diff --git a/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status_content.tsx b/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status_content.tsx index 5d9d23e2e9..1c908bd728 100644 --- a/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status_content.tsx +++ b/app/javascript/flavours/glitch/features/notifications_v2/components/embedded_status_content.tsx @@ -46,11 +46,15 @@ export const EmbeddedStatusContent: React.FC<{ () => (status.get('mentions') as List).toJS(), [status], ); - const htmlHandlers = useElementHandledLink({ - hashtagAccountId: status.get('account') as string | undefined, - hrefToMention(href) { + const hrefToMention = useCallback( + (href: string) => { return mentions.find((item) => item.url === href); }, + [mentions], + ); + const htmlHandlers = useElementHandledLink({ + hashtagAccountId: status.get('account') as string | undefined, + hrefToMention, }); const handleContentRef = useCallback(