2021-09-09 16:29:01 +00:00
|
|
|
// 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';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { StateType } from '../reducer';
|
2021-09-09 16:29:01 +00:00
|
|
|
import { useActions as usePreferredReactionsActions } from '../ducks/preferredReactions';
|
2021-09-09 20:53:26 +00:00
|
|
|
import { useActions as useItemsActions } from '../ducks/items';
|
2020-10-02 20:05:09 +00:00
|
|
|
|
|
|
|
import { getIntl } from '../selectors/user';
|
2021-09-09 23:47:30 +00:00
|
|
|
import { getPreferredReactionEmoji } from '../selectors/items';
|
2020-10-02 20:05:09 +00:00
|
|
|
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../../types/Util';
|
|
|
|
import type { Props } from '../../components/conversation/ReactionPicker';
|
|
|
|
import { ReactionPicker } from '../../components/conversation/ReactionPicker';
|
2020-10-02 20:05:09 +00:00
|
|
|
|
2021-09-09 16:29:01 +00:00
|
|
|
type ExternalProps = Omit<
|
|
|
|
Props,
|
|
|
|
| 'i18n'
|
2021-09-09 20:53:26 +00:00
|
|
|
| 'onSetSkinTone'
|
2021-09-09 16:29:01 +00:00
|
|
|
| 'openCustomizePreferredReactionsModal'
|
|
|
|
| 'preferredReactionEmoji'
|
|
|
|
| 'selectionStyle'
|
|
|
|
| 'skinTone'
|
|
|
|
>;
|
2020-10-02 20:05:09 +00:00
|
|
|
|
|
|
|
export const SmartReactionPicker = React.forwardRef<
|
|
|
|
HTMLDivElement,
|
|
|
|
ExternalProps
|
2022-11-18 00:45:19 +00:00
|
|
|
>(function SmartReactionPickerInner(props, ref) {
|
2021-11-11 22:43:05 +00:00
|
|
|
const { openCustomizePreferredReactionsModal } =
|
|
|
|
usePreferredReactionsActions();
|
2021-09-09 20:53:26 +00:00
|
|
|
const { onSetSkinTone } = useItemsActions();
|
2021-09-09 16:29:01 +00:00
|
|
|
|
2020-10-02 20:05:09 +00:00
|
|
|
const i18n = useSelector<StateType, LocalizerType>(getIntl);
|
|
|
|
|
2022-12-22 00:07:02 +00:00
|
|
|
const preferredReactionEmoji = useSelector<StateType, ReadonlyArray<string>>(
|
2021-09-09 16:29:01 +00:00
|
|
|
getPreferredReactionEmoji
|
|
|
|
);
|
|
|
|
|
2020-10-02 20:05:09 +00:00
|
|
|
return (
|
2021-09-09 16:29:01 +00:00
|
|
|
<ReactionPicker
|
|
|
|
i18n={i18n}
|
2021-09-09 20:53:26 +00:00
|
|
|
onSetSkinTone={onSetSkinTone}
|
2021-09-09 16:29:01 +00:00
|
|
|
openCustomizePreferredReactionsModal={
|
|
|
|
openCustomizePreferredReactionsModal
|
|
|
|
}
|
|
|
|
preferredReactionEmoji={preferredReactionEmoji}
|
|
|
|
ref={ref}
|
|
|
|
{...props}
|
|
|
|
/>
|
2020-10-02 20:05:09 +00:00
|
|
|
);
|
|
|
|
});
|