@@ -7,18 +7,14 @@ import { useForceUpdate, useGroupChannelHandler } from '@sendbird/uikit-tools';
7
7
import type { SendbirdBaseChannel , SendbirdBaseMessage , SendbirdReaction } from '@sendbird/uikit-utils' ;
8
8
import { getReactionCount } from '@sendbird/uikit-utils' ;
9
9
10
- import { DEFAULT_LONG_PRESS_DELAY , UNKNOWN_USER_ID } from '../../constants' ;
10
+ import { DEFAULT_LONG_PRESS_DELAY } from '../../constants' ;
11
11
import { useReaction , useSendbirdChat } from '../../hooks/useContext' ;
12
12
import ReactionRoundedButton from './ReactionRoundedButton' ;
13
13
14
14
const NUM_COL = 4 ;
15
15
const REACTION_MORE_KEY = 'reaction-more-button' ;
16
16
export type ReactionAddonType = 'default' | 'thread_parent_message' ;
17
17
18
- const getUserReacted = ( reaction : SendbirdReaction , userId = UNKNOWN_USER_ID ) => {
19
- return reaction . userIds . indexOf ( userId ) > - 1 ;
20
- } ;
21
-
22
18
const createOnPressReaction = (
23
19
reaction : SendbirdReaction ,
24
20
channel : SendbirdBaseChannel ,
@@ -41,7 +37,6 @@ const createReactionButtons = (
41
37
emojiLimit : number ,
42
38
onOpenReactionList : ( ) => void ,
43
39
onOpenReactionUserList : ( focusIndex : number ) => void ,
44
- currentUserId ?: string ,
45
40
reactionAddonType ?: ReactionAddonType ,
46
41
) => {
47
42
const reactions = message . reactions ?? [ ] ;
@@ -51,15 +46,15 @@ const createReactionButtons = (
51
46
return (
52
47
< Pressable
53
48
key = { reaction . key }
54
- onPress = { createOnPressReaction ( reaction , channel , message , getUserReacted ( reaction , currentUserId ) ) }
49
+ onPress = { createOnPressReaction ( reaction , channel , message , reaction . hasCurrentUserReacted ) }
55
50
onLongPress = { ( ) => onOpenReactionUserList ( index ) }
56
51
delayLongPress = { DEFAULT_LONG_PRESS_DELAY }
57
52
>
58
53
{ ( { pressed } ) => (
59
54
< ReactionRoundedButton
60
55
url = { getEmoji ( reaction . key ) . url }
61
56
count = { getReactionCount ( reaction ) }
62
- reacted = { pressed || getUserReacted ( reaction , currentUserId ) }
57
+ reacted = { pressed || reaction . hasCurrentUserReacted }
63
58
style = {
64
59
reactionAddonType === 'default'
65
60
? [ isNotLastOfRow && styles . marginRight , isNotLastOfCol && styles . marginBottom ]
@@ -91,7 +86,7 @@ const MessageReactionAddon = ({
91
86
reactionAddonType ?: ReactionAddonType ;
92
87
} ) => {
93
88
const { colors } = useUIKitTheme ( ) ;
94
- const { sdk, emojiManager, currentUser } = useSendbirdChat ( ) ;
89
+ const { sdk, emojiManager } = useSendbirdChat ( ) ;
95
90
const { openReactionList, openReactionUserList } = useReaction ( ) ;
96
91
const forceUpdate = useForceUpdate ( ) ;
97
92
@@ -113,7 +108,6 @@ const MessageReactionAddon = ({
113
108
emojiManager . allEmoji . length ,
114
109
( ) => openReactionList ( { channel, message } ) ,
115
110
( focusIndex ) => openReactionUserList ( { channel, message, focusIndex } ) ,
116
- currentUser ?. userId ,
117
111
reactionAddonType ,
118
112
) ;
119
113
0 commit comments