From 23580c9de76c33d054d457052487e289771a85d5 Mon Sep 17 00:00:00 2001 From: array-in-a-matrix Date: Sat, 8 Apr 2023 01:36:28 -0400 Subject: [PATCH] remove twemoji --- src/app/molecules/message/Message.jsx | 12 +++--------- src/app/molecules/room-profile/RoomProfile.jsx | 2 +- src/app/molecules/room-tile/RoomTile.jsx | 2 +- src/app/organisms/emoji-board/EmojiBoard.jsx | 2 +- src/app/organisms/room/RoomViewCmdBar.jsx | 12 ++---------- src/app/organisms/room/RoomViewContent.jsx | 2 +- src/app/organisms/space-manage/SpaceManage.jsx | 2 +- src/util/twemojify.jsx | 14 +++++--------- 8 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/app/molecules/message/Message.jsx b/src/app/molecules/message/Message.jsx index 26a5b29..826a129 100644 --- a/src/app/molecules/message/Message.jsx +++ b/src/app/molecules/message/Message.jsx @@ -210,19 +210,13 @@ const MessageBody = React.memo(({ let content = null; if (isCustomHTML) { try { - content = twemojify( - sanitizeCustomHtml(initMatrix.matrixClient, body), - undefined, - true, - false, - true, - ); + content = twemojify(sanitizeCustomHtml(initMatrix.matrixClient, body), undefined, true, false); } catch { console.error('Malformed custom html: ', body); - content = twemojify(body, undefined); + content = twemojify(body); } } else { - content = twemojify(body, undefined, true); + content = twemojify(body); } // Determine if this message should render with large emojis diff --git a/src/app/molecules/room-profile/RoomProfile.jsx b/src/app/molecules/room-profile/RoomProfile.jsx index 2181198..6bcb01d 100644 --- a/src/app/molecules/room-profile/RoomProfile.jsx +++ b/src/app/molecules/room-profile/RoomProfile.jsx @@ -161,7 +161,7 @@ function RoomProfile({ roomId }) { )} {room.getCanonicalAlias() || room.roomId} - {roomTopic && {twemojify(roomTopic, undefined, true)}} + {roomTopic && {twemojify(roomTopic)}} ); diff --git a/src/app/molecules/room-tile/RoomTile.jsx b/src/app/molecules/room-tile/RoomTile.jsx index 95481ec..ad9f02e 100644 --- a/src/app/molecules/room-tile/RoomTile.jsx +++ b/src/app/molecules/room-tile/RoomTile.jsx @@ -33,7 +33,7 @@ function RoomTile({ { desc !== null && (typeof desc === 'string') - ? {twemojify(desc, undefined, true)} + ? {twemojify(desc)} : desc } diff --git a/src/app/organisms/emoji-board/EmojiBoard.jsx b/src/app/organisms/emoji-board/EmojiBoard.jsx index ab865d6..243df08 100644 --- a/src/app/organisms/emoji-board/EmojiBoard.jsx +++ b/src/app/organisms/emoji-board/EmojiBoard.jsx @@ -338,7 +338,7 @@ function EmojiBoard({ onSelect, searchRef }) {
-
{parse(twemoji.parse('🙂', { base: TWEMOJI_BASE_URL }))}
+
{parse('🙂')}
:slight_smile:
diff --git a/src/app/organisms/room/RoomViewCmdBar.jsx b/src/app/organisms/room/RoomViewCmdBar.jsx index 0d21123..8b14053 100644 --- a/src/app/organisms/room/RoomViewCmdBar.jsx +++ b/src/app/organisms/room/RoomViewCmdBar.jsx @@ -5,7 +5,7 @@ import './RoomViewCmdBar.scss'; import parse from 'html-react-parser'; import twemoji from 'twemoji'; -import { twemojify, TWEMOJI_BASE_URL } from '../../../util/twemojify'; +import { twemojify } from '../../../util/twemojify'; import initMatrix from '../../../client/initMatrix'; import { getEmojiForCompletion } from '../emoji-board/custom-emoji'; @@ -53,15 +53,7 @@ function renderSuggestions({ prefix, option, suggestions }, fireCmd) { // Renders a small Twemoji function renderTwemoji(emoji) { - return parse( - twemoji.parse(emoji.unicode, { - attributes: () => ({ - unicode: emoji.unicode, - shortcodes: emoji.shortcodes?.toString(), - }), - base: TWEMOJI_BASE_URL, - }) - ); + return parse(emoji.unicode); } // Render a custom emoji diff --git a/src/app/organisms/room/RoomViewContent.jsx b/src/app/organisms/room/RoomViewContent.jsx index 745ece8..1e56a76 100644 --- a/src/app/organisms/room/RoomViewContent.jsx +++ b/src/app/organisms/room/RoomViewContent.jsx @@ -62,7 +62,7 @@ function RoomIntroContainer({ event, timeline }) { avatarSrc = isDM ? room.getAvatarFallbackMember()?.getAvatarUrl(mx.baseUrl, 80, 80, 'crop') : avatarSrc; const heading = isDM ? room.name : `Welcome to ${room.name}`; - const topic = twemojify(roomTopic || '', undefined, true); + const topic = twemojify(roomTopic || ''); const nameJsx = twemojify(room.name); const desc = isDM ? ( diff --git a/src/app/organisms/space-manage/SpaceManage.jsx b/src/app/organisms/space-manage/SpaceManage.jsx index cf042da..3f090f2 100644 --- a/src/app/organisms/space-manage/SpaceManage.jsx +++ b/src/app/organisms/space-manage/SpaceManage.jsx @@ -151,7 +151,7 @@ function SpaceManageItem({ : } - {isExpand && roomInfo.topic && {twemojify(roomInfo.topic, undefined, true)}} + {isExpand && roomInfo.topic && {twemojify(roomInfo.topic)}} ); } diff --git a/src/util/twemojify.jsx b/src/util/twemojify.jsx index d17a32c..a4e02f7 100644 --- a/src/util/twemojify.jsx +++ b/src/util/twemojify.jsx @@ -30,20 +30,16 @@ const mathOptions = { }; /** - * @param {string} text - text to twemojify - * @param {object|undefined} opts - options for tweomoji.parse - * @param {boolean} [linkify=false] - convert links to html tags (default: false) + * @param {string} text - text + * @param {undefined} opts + * @param {boolean} [linkify=true] - convert links to html tags (default: true) * @param {boolean} [sanitize=true] - sanitize html text (default: true) - * @param {boolean} [maths=false] - render maths (default: false) + * @param {boolean} [maths=true] - render maths (default: true) * @returns React component */ -export function twemojify(text, opts, linkify = false, sanitize = true, maths = true) { +export function twemojify(text, opts, linkify = true, sanitize = true, maths = true) { if (typeof text !== 'string') return text; let content = text; - const options = opts ?? { base: TWEMOJI_BASE_URL }; - if (!options.base) { - options.base = TWEMOJI_BASE_URL; - } if (sanitize) { content = sanitizeText(content);