-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathBasePopoverReactionList.tsx
60 lines (56 loc) · 2.62 KB
/
BasePopoverReactionList.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React, {forwardRef, useImperativeHandle} from 'react';
import type {ForwardedRef} from 'react';
import {withOnyx} from 'react-native-onyx';
import PopoverWithMeasuredContent from '@components/PopoverWithMeasuredContent';
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
import useBasePopoverReactionList from '@hooks/useBasePopoverReactionList';
import type {BasePopoverReactionListOnyxProps, BasePopoverReactionListPropsWithLocalWithOnyx} from '@hooks/useBasePopoverReactionList/types';
import useLocalize from '@hooks/useLocalize';
import BaseReactionList from '@pages/home/report/ReactionList/BaseReactionList';
import type {ReactionListRef} from '@pages/home/ReportScreenContext';
import ONYXKEYS from '@src/ONYXKEYS';
function BasePopoverReactionList(props: BasePopoverReactionListPropsWithLocalWithOnyx, ref: ForwardedRef<Partial<ReactionListRef>>) {
const {emojiReactions, emojiName, reportActionID, currentUserPersonalDetails} = props;
const {preferredLocale} = useLocalize();
const {isPopoverVisible, hideReactionList, showReactionList, popoverAnchorPosition, reactionListRef, getReactionInformation} = useBasePopoverReactionList({
emojiName,
emojiReactions,
accountID: currentUserPersonalDetails.accountID,
reportActionID,
preferredLocale,
});
// Get the reaction information
const {emojiCodes, reactionCount, hasUserReacted, users} = getReactionInformation();
useImperativeHandle(ref, () => ({hideReactionList, showReactionList}));
return (
<PopoverWithMeasuredContent
isVisible={isPopoverVisible}
onClose={hideReactionList}
anchorPosition={popoverAnchorPosition}
animationIn="fadeIn"
disableAnimation={false}
animationOutTiming={1}
shouldSetModalVisibility={false}
fullscreen
withoutOverlay
anchorRef={reactionListRef}
>
<BaseReactionList
isVisible
users={users}
emojiName={emojiName}
emojiCodes={emojiCodes}
emojiCount={reactionCount}
onClose={hideReactionList}
hasUserReacted={hasUserReacted}
/>
</PopoverWithMeasuredContent>
);
}
export default withCurrentUserPersonalDetails(
withOnyx<BasePopoverReactionListPropsWithLocalWithOnyx, BasePopoverReactionListOnyxProps>({
emojiReactions: {
key: ({reportActionID}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS_REACTIONS}${reportActionID}`,
},
})(forwardRef(BasePopoverReactionList)),
);