Skip to content

Commit

Permalink
regression: Emojis taking too long to render on EmojiPicker (Rocket…
Browse files Browse the repository at this point in the history
…Chat#29603)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
dougfabris and kodiakhq[bot] authored Jun 21, 2023
1 parent e65933b commit 5132e6d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 29 deletions.
2 changes: 1 addition & 1 deletion apps/meteor/app/emoji/client/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const createEmojiList = (
if (!image) {
continue;
}
emojiList.push({ emoji: current, image, emojiHandle: emojiToRender });
emojiList.push({ emoji: current, image });
}
});

Expand Down
1 change: 0 additions & 1 deletion apps/meteor/app/emoji/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { TranslationKey } from '@rocket.chat/ui-contexts';
export type EmojiItem = {
emoji: string;
image: string;
emojiHandle: string;
};

export type EmojiCategory = {
Expand Down
14 changes: 2 additions & 12 deletions apps/meteor/client/components/message/toolbox/Toolbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,8 @@ const Toolbox = ({ message, messageContext, room, subscription }: ToolboxProps):
return (
<MessageToolbox>
{recentList.length > 0 &&
recentList.slice(0, 3).map(({ emoji, image, emojiHandle }) => {
return (
<EmojiElement
small
key={emoji}
title={emoji}
emoji={emoji}
image={image}
emojiHandle={emojiHandle}
onClick={() => handleSetReaction(emoji)}
/>
);
recentList.slice(0, 3).map(({ emoji, image }) => {
return <EmojiElement small key={emoji} title={emoji} emoji={emoji} image={image} onClick={() => handleSetReaction(emoji)} />;
})}
{actionsQueryResult.data?.message.map((action) => (
<MessageToolboxItem
Expand Down
14 changes: 4 additions & 10 deletions apps/meteor/client/views/composer/EmojiPicker/EmojiCategoryRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,14 @@ const EmojiCategoryRow = ({
<>
{categoryKey === CUSTOM_CATEGORY &&
emojis.list.map(
({ emoji, image, emojiHandle }, index = 1) =>
({ emoji, image }, index = 1) =>
index < customItemsLimit && (
<EmojiElement
key={emoji + categoryKey}
emoji={emoji}
image={image}
emojiHandle={emojiHandle}
onClick={handleSelectEmoji}
/>
<EmojiElement key={emoji + categoryKey} emoji={emoji} image={image} onClick={handleSelectEmoji} />
),
)}
{!(categoryKey === CUSTOM_CATEGORY) &&
emojis.list.map(({ emoji, image, emojiHandle }) => (
<EmojiElement key={emoji + categoryKey} emoji={emoji} image={image} emojiHandle={emojiHandle} onClick={handleSelectEmoji} />
emojis.list.map(({ emoji, image }) => (
<EmojiElement key={emoji + categoryKey} emoji={emoji} image={image} onClick={handleSelectEmoji} />
))}
</>
</EmojiPickerCategoryWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@ import type { MouseEvent, AllHTMLAttributes } from 'react';
import React, { memo } from 'react';

import type { EmojiItem } from '../../../../app/emoji/client';
import Emoji from '../../../components/Emoji';
import { usePreviewEmoji } from '../../../contexts/EmojiPickerContext';

type EmojiElementProps = EmojiItem & { small?: boolean; onClick: (e: MouseEvent<HTMLElement>) => void } & Omit<
AllHTMLAttributes<HTMLButtonElement>,
'is'
>;

const EmojiElement = ({ emoji, image, emojiHandle, onClick, small = false, ...props }: EmojiElementProps) => {
const EmojiElement = ({ emoji, image, onClick, small = false, ...props }: EmojiElementProps) => {
const { handlePreview, handleRemovePreview } = usePreviewEmoji();

if (!image) {
return null;
}

const emojiSmallClass = css`
> .emoji,
.emojione {
Expand All @@ -23,7 +26,7 @@ const EmojiElement = ({ emoji, image, emojiHandle, onClick, small = false, ...pr
}
`;

const emojiElement = <Emoji emojiHandle={emojiHandle} />;
const emojiElement = <div dangerouslySetInnerHTML={{ __html: image }} />;

return (
<IconButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ const SearchingResult = ({ searchResults, handleSelectEmoji }: SearchingResultPr
List: SearchingResultWrapper,
}}
itemContent={(index) => {
const { emoji, image, emojiHandle } = searchResults[index] || {};
return <EmojiElement emoji={emoji} image={image} emojiHandle={emojiHandle} onClick={handleSelectEmoji} />;
const { emoji, image } = searchResults[index] || {};
return <EmojiElement emoji={emoji} image={image} onClick={handleSelectEmoji} />;
}}
/>
);
Expand Down

0 comments on commit 5132e6d

Please sign in to comment.