signal-desktop/ts/state/smart/EmojiPicker.tsx

54 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import React, { useCallback, forwardRef, memo } from 'react';
import { useSelector } from 'react-redux';
2021-04-27 22:35:35 +00:00
import { useRecentEmojis } from '../selectors/emojis';
2024-03-12 16:29:31 +00:00
import { useEmojisActions as useEmojiActions } from '../ducks/emojis';
import type { Props as EmojiPickerProps } from '../../components/emoji/EmojiPicker';
import { EmojiPicker } from '../../components/emoji/EmojiPicker';
import { getIntl } from '../selectors/user';
import { getEmojiSkinTone } from '../selectors/items';
export const SmartEmojiPicker = memo(
forwardRef<
HTMLDivElement,
Pick<
EmojiPickerProps,
'onClickSettings' | 'onPickEmoji' | 'onSetSkinTone' | 'onClose' | 'style'
>
>(function SmartEmojiPickerInner(
{ onClickSettings, onPickEmoji, onSetSkinTone, onClose, style },
ref
) {
const i18n = useSelector(getIntl);
const skinTone = useSelector(getEmojiSkinTone);
const recentEmojis = useRecentEmojis();
const { onUseEmoji } = useEmojiActions();
const handlePickEmoji = useCallback(
data => {
onUseEmoji({ shortName: data.shortName });
onPickEmoji(data);
},
[onUseEmoji, onPickEmoji]
);
return (
<EmojiPicker
i18n={i18n}
onClickSettings={onClickSettings}
onClose={onClose}
onSetSkinTone={onSetSkinTone}
onPickEmoji={handlePickEmoji}
recentEmojis={recentEmojis}
ref={ref}
skinTone={skinTone}
style={style}
wasInvokedFromKeyboard={false}
/>
);
})
);