2021-09-09 16:29:01 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import type { LocalizerType } from '../../types/Util';
|
|
|
|
import { useActions as usePreferredReactionsActions } from '../ducks/preferredReactions';
|
|
|
|
import { useActions as useItemsActions } from '../ducks/items';
|
|
|
|
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';
|
|
|
|
|
|
|
|
export function SmartCustomizingPreferredReactionsModal(): JSX.Element {
|
|
|
|
const preferredReactionsActions = usePreferredReactionsActions();
|
|
|
|
const { onSetSkinTone } = useItemsActions();
|
|
|
|
|
|
|
|
const i18n = useSelector<StateType, LocalizerType>(getIntl);
|
|
|
|
|
|
|
|
const customizeModalState = useSelector<
|
|
|
|
StateType,
|
|
|
|
ReturnType<typeof getCustomizeModalState>
|
|
|
|
>(state => getCustomizeModalState(state));
|
|
|
|
|
2021-09-10 18:43:17 +00:00
|
|
|
const recentEmojis = useRecentEmojis();
|
|
|
|
|
2021-09-09 16:29:01 +00:00
|
|
|
const skinTone = useSelector<StateType, number>(state =>
|
|
|
|
getEmojiSkinTone(state)
|
|
|
|
);
|
|
|
|
|
2021-09-10 22:50:56 +00:00
|
|
|
if (!customizeModalState) {
|
|
|
|
throw new Error(
|
|
|
|
'<SmartCustomizingPreferredReactionsModal> requires a modal'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-09-09 16:29:01 +00:00
|
|
|
return (
|
|
|
|
<CustomizingPreferredReactionsModal
|
|
|
|
i18n={i18n}
|
|
|
|
onSetSkinTone={onSetSkinTone}
|
2021-09-10 18:43:17 +00:00
|
|
|
recentEmojis={recentEmojis}
|
2021-09-09 16:29:01 +00:00
|
|
|
skinTone={skinTone}
|
|
|
|
{...preferredReactionsActions}
|
|
|
|
{...customizeModalState}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|