From f870904e5fa50cdf65de82a49ad9560c0770d3d7 Mon Sep 17 00:00:00 2001 From: Echo Date: Tue, 7 Oct 2025 17:21:50 +0200 Subject: [PATCH] [Glitch] Emoji: Bypass legacy emoji normalization Port 3c9b828c714c71598493fe39231175bb156ef6fd to glitch-soc Signed-off-by: Claire --- .../flavours/glitch/components/account_bio.tsx | 2 +- .../glitch/components/display_name/no-domain.tsx | 8 +------- .../glitch/components/display_name/simple.tsx | 8 +------- .../flavours/glitch/components/status_content.jsx | 3 --- .../flavours/glitch/entrypoints/public.tsx | 2 +- .../flavours/glitch/features/emoji/emoji.js | 13 ++++++++++++- 6 files changed, 16 insertions(+), 20 deletions(-) diff --git a/app/javascript/flavours/glitch/components/account_bio.tsx b/app/javascript/flavours/glitch/components/account_bio.tsx index 8c221239ef..f620d9c090 100644 --- a/app/javascript/flavours/glitch/components/account_bio.tsx +++ b/app/javascript/flavours/glitch/components/account_bio.tsx @@ -61,7 +61,7 @@ export const AccountBio: React.FC = ({ if (!account) { return ''; } - return isModernEmojiEnabled() ? account.note : account.note_emojified; + return account.note_emojified; }); const extraEmojis = useAppSelector((state) => { const account = state.accounts.get(accountId); diff --git a/app/javascript/flavours/glitch/components/display_name/no-domain.tsx b/app/javascript/flavours/glitch/components/display_name/no-domain.tsx index 5320fba090..ee6e84050c 100644 --- a/app/javascript/flavours/glitch/components/display_name/no-domain.tsx +++ b/app/javascript/flavours/glitch/components/display_name/no-domain.tsx @@ -2,8 +2,6 @@ import type { ComponentPropsWithoutRef, FC } from 'react'; import classNames from 'classnames'; -import { isModernEmojiEnabled } from '@/flavours/glitch/utils/environment'; - import { AnimateEmojiProvider } from '../emoji/context'; import { EmojiHTML } from '../emoji/html'; import { Skeleton } from '../skeleton'; @@ -24,11 +22,7 @@ export const DisplayNameWithoutDomain: FC< {account ? ( diff --git a/app/javascript/flavours/glitch/components/display_name/simple.tsx b/app/javascript/flavours/glitch/components/display_name/simple.tsx index 901b0b8fd4..29d9ee217b 100644 --- a/app/javascript/flavours/glitch/components/display_name/simple.tsx +++ b/app/javascript/flavours/glitch/components/display_name/simple.tsx @@ -1,7 +1,5 @@ import type { ComponentPropsWithoutRef, FC } from 'react'; -import { isModernEmojiEnabled } from '@/flavours/glitch/utils/environment'; - import { EmojiHTML } from '../emoji/html'; import type { DisplayNameProps } from './index'; @@ -19,11 +17,7 @@ export const DisplayNameSimple: FC< diff --git a/app/javascript/flavours/glitch/components/status_content.jsx b/app/javascript/flavours/glitch/components/status_content.jsx index 4cf47adda5..d3c48dcbe9 100644 --- a/app/javascript/flavours/glitch/components/status_content.jsx +++ b/app/javascript/flavours/glitch/components/status_content.jsx @@ -84,9 +84,6 @@ const isLinkMisleading = (link) => { * @returns {string} */ export function getStatusContent(status) { - if (isModernEmojiEnabled()) { - return status.getIn(['translation', 'content']) || status.get('content'); - } return status.getIn(['translation', 'contentHtml']) || status.get('contentHtml'); } diff --git a/app/javascript/flavours/glitch/entrypoints/public.tsx b/app/javascript/flavours/glitch/entrypoints/public.tsx index 105b877bc7..f4300bc119 100644 --- a/app/javascript/flavours/glitch/entrypoints/public.tsx +++ b/app/javascript/flavours/glitch/entrypoints/public.tsx @@ -70,7 +70,7 @@ function loaded() { }; document.querySelectorAll('.emojify').forEach((content) => { - content.innerHTML = emojify(content.innerHTML); + content.innerHTML = emojify(content.innerHTML, {}, true); // Force emojify as public doesn't load the new emoji system. }); document diff --git a/app/javascript/flavours/glitch/features/emoji/emoji.js b/app/javascript/flavours/glitch/features/emoji/emoji.js index 55fc382a5d..cc4948a6c6 100644 --- a/app/javascript/flavours/glitch/features/emoji/emoji.js +++ b/app/javascript/flavours/glitch/features/emoji/emoji.js @@ -1,5 +1,6 @@ import Trie from 'substring-trie'; +import { isModernEmojiEnabled } from '@/flavours/glitch/utils/environment'; import { assetHost } from 'flavours/glitch/utils/config'; import { autoPlayGif, useSystemEmojiFont } from '../../initial_state'; @@ -148,7 +149,17 @@ const emojifyNode = (node, customEmojis) => { } }; -const emojify = (str, customEmojis = {}) => { +/** + * Legacy emoji processing function. + * @param {string} str + * @param {object} customEmojis + * @param {boolean} force If true, always emojify even if modern emoji is enabled + * @returns {string} + */ +const emojify = (str, customEmojis = {}, force = false) => { + if (isModernEmojiEnabled() && !force) { + return str; + } const wrapper = document.createElement('div'); wrapper.innerHTML = str;