2021-09-09 16:29:01 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
2024-03-13 20:44:13 +00:00
|
|
|
import React, { memo } from 'react';
|
2021-09-09 16:29:01 +00:00
|
|
|
import { useSelector } from 'react-redux';
|
2024-03-12 16:29:31 +00:00
|
|
|
import { usePreferredReactionsActions } from '../ducks/preferredReactions';
|
2023-08-09 00:53:06 +00:00
|
|
|
import { useItemsActions } from '../ducks/items';
|
2021-09-09 16:29:01 +00:00
|
|
|
import { getIntl } from '../selectors/user';
|
|
|
|
import { getEmojiSkinTone } from '../selectors/items';
|
2021-09-10 18:43:17 +00:00
|
|
|
import { useRecentEmojis } from '../selectors/emojis';
|
2021-09-09 16:29:01 +00:00
|
|
|
import { getCustomizeModalState } from '../selectors/preferredReactions';
|
|
|
|
import { CustomizingPreferredReactionsModal } from '../../components/CustomizingPreferredReactionsModal';
|
2024-03-13 20:44:13 +00:00
|
|
|
import { strictAssert } from '../../util/assert';
|
2021-09-09 16:29:01 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
export const SmartCustomizingPreferredReactionsModal = memo(
|
|
|
|
function SmartCustomizingPreferredReactionsModal(): JSX.Element {
|
|
|
|
const i18n = useSelector(getIntl);
|
|
|
|
const customizeModalState = useSelector(getCustomizeModalState);
|
|
|
|
const skinTone = useSelector(getEmojiSkinTone);
|
|
|
|
const recentEmojis = useRecentEmojis();
|
2021-09-09 16:29:01 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
const {
|
|
|
|
cancelCustomizePreferredReactionsModal,
|
|
|
|
deselectDraftEmoji,
|
|
|
|
replaceSelectedDraftEmoji,
|
|
|
|
resetDraftEmoji,
|
|
|
|
savePreferredReactions,
|
|
|
|
selectDraftEmojiToBeReplaced,
|
|
|
|
} = usePreferredReactionsActions();
|
|
|
|
const { onSetSkinTone } = useItemsActions();
|
2021-09-09 16:29:01 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
strictAssert(
|
|
|
|
customizeModalState != null,
|
|
|
|
'<SmartCustomizingPreferredReactionsModal> requires a modal'
|
|
|
|
);
|
2021-09-10 18:43:17 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
const {
|
|
|
|
hadSaveError,
|
|
|
|
isSaving,
|
|
|
|
draftPreferredReactions,
|
|
|
|
originalPreferredReactions,
|
|
|
|
selectedDraftEmojiIndex,
|
|
|
|
} = customizeModalState;
|
2021-09-09 16:29:01 +00:00
|
|
|
|
2024-03-13 20:44:13 +00:00
|
|
|
return (
|
|
|
|
<CustomizingPreferredReactionsModal
|
|
|
|
cancelCustomizePreferredReactionsModal={
|
|
|
|
cancelCustomizePreferredReactionsModal
|
|
|
|
}
|
|
|
|
deselectDraftEmoji={deselectDraftEmoji}
|
|
|
|
draftPreferredReactions={draftPreferredReactions}
|
|
|
|
hadSaveError={hadSaveError}
|
|
|
|
i18n={i18n}
|
|
|
|
isSaving={isSaving}
|
|
|
|
onSetSkinTone={onSetSkinTone}
|
|
|
|
originalPreferredReactions={originalPreferredReactions}
|
|
|
|
recentEmojis={recentEmojis}
|
|
|
|
replaceSelectedDraftEmoji={replaceSelectedDraftEmoji}
|
|
|
|
resetDraftEmoji={resetDraftEmoji}
|
|
|
|
savePreferredReactions={savePreferredReactions}
|
|
|
|
selectDraftEmojiToBeReplaced={selectDraftEmojiToBeReplaced}
|
|
|
|
selectedDraftEmojiIndex={selectedDraftEmojiIndex}
|
|
|
|
skinTone={skinTone}
|
|
|
|
/>
|
2021-09-10 22:50:56 +00:00
|
|
|
);
|
|
|
|
}
|
2024-03-13 20:44:13 +00:00
|
|
|
);
|