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

57 lines
1.5 KiB
TypeScript
Raw Normal View History

// Copyright 2020-2021 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-10-02 20:05:09 +00:00
import * as React from 'react';
import { useSelector } from 'react-redux';
import { StateType } from '../reducer';
import { useActions as usePreferredReactionsActions } from '../ducks/preferredReactions';
import { useActions as useItemsActions } from '../ducks/items';
2020-10-02 20:05:09 +00:00
import { getIntl } from '../selectors/user';
import { getPreferredReactionEmoji } from '../selectors/items';
2020-10-02 20:05:09 +00:00
import { LocalizerType } from '../../types/Util';
import {
ReactionPicker,
Props,
} from '../../components/conversation/ReactionPicker';
type ExternalProps = Omit<
Props,
| 'i18n'
| 'onSetSkinTone'
| 'openCustomizePreferredReactionsModal'
| 'preferredReactionEmoji'
| 'selectionStyle'
| 'skinTone'
>;
2020-10-02 20:05:09 +00:00
export const SmartReactionPicker = React.forwardRef<
HTMLDivElement,
ExternalProps
>((props, ref) => {
const {
openCustomizePreferredReactionsModal,
} = usePreferredReactionsActions();
const { onSetSkinTone } = useItemsActions();
2020-10-02 20:05:09 +00:00
const i18n = useSelector<StateType, LocalizerType>(getIntl);
const preferredReactionEmoji = useSelector<StateType, Array<string>>(
getPreferredReactionEmoji
);
2020-10-02 20:05:09 +00:00
return (
<ReactionPicker
i18n={i18n}
onSetSkinTone={onSetSkinTone}
openCustomizePreferredReactionsModal={
openCustomizePreferredReactionsModal
}
preferredReactionEmoji={preferredReactionEmoji}
ref={ref}
{...props}
/>
2020-10-02 20:05:09 +00:00
);
});