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

61 lines
1.7 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
2020-10-02 20:05:09 +00:00
import * as React from 'react';
import { useSelector } from 'react-redux';
import type { StateType } from '../reducer';
import { useActions as usePreferredReactionsActions } from '../ducks/preferredReactions';
2023-08-09 00:53:06 +00:00
import { 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 type { LocalizerType } from '../../types/Util';
2023-11-16 19:55:35 +00:00
import type { Props as InternalProps } from '../../components/conversation/ReactionPicker';
import { ReactionPicker } from '../../components/conversation/ReactionPicker';
2020-10-02 20:05:09 +00:00
type ExternalProps = Omit<
2023-11-16 19:55:35 +00:00
InternalProps,
| 'i18n'
| 'onSetSkinTone'
| 'openCustomizePreferredReactionsModal'
| 'preferredReactionEmoji'
| 'selectionStyle'
| 'skinTone'
2023-11-16 19:55:35 +00:00
> & {
preferredReactionEmoji?: ReadonlyArray<string>;
};
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) {
2023-11-16 19:55:35 +00:00
const { preferredReactionEmoji } = props;
2021-11-11 22:43:05 +00:00
const { openCustomizePreferredReactionsModal } =
usePreferredReactionsActions();
2023-11-16 19:55:35 +00:00
const { onSetSkinTone } = useItemsActions();
2020-10-02 20:05:09 +00:00
const i18n = useSelector<StateType, LocalizerType>(getIntl);
2023-11-16 19:55:35 +00:00
const statePreferredReactionEmoji = useSelector<
StateType,
ReadonlyArray<string>
>(getPreferredReactionEmoji);
2020-10-02 20:05:09 +00:00
return (
<ReactionPicker
i18n={i18n}
onSetSkinTone={onSetSkinTone}
openCustomizePreferredReactionsModal={
openCustomizePreferredReactionsModal
}
ref={ref}
{...props}
2023-11-16 19:55:35 +00:00
preferredReactionEmoji={
preferredReactionEmoji ?? statePreferredReactionEmoji
}
/>
2020-10-02 20:05:09 +00:00
);
});