diff --git a/native/chat/reaction-message-utils.js b/native/chat/reaction-message-utils.js --- a/native/chat/reaction-message-utils.js +++ b/native/chat/reaction-message-utils.js @@ -9,15 +9,21 @@ } from 'lib/actions/message-actions'; import type { BindServerCall, DispatchFunctions } from 'lib/utils/action-utils'; +import type { InputState } from '../input/input-state'; +import type { AppNavigationProp } from '../navigation/app-navigator.react'; +import type { MessageTooltipRouteNames } from '../navigation/route-names'; import type { TooltipRoute } from '../navigation/tooltip.react'; +import type { ChatContextType } from './chat-context'; -function onPressReact( - route: - | TooltipRoute<'TextMessageTooltipModal'> - | TooltipRoute<'MultimediaMessageTooltipModal'> - | TooltipRoute<'RobotextMessageTooltipModal'>, +function onPressReact( + route: TooltipRoute, dispatchFunctions: DispatchFunctions, bindServerCall: BindServerCall, + inputState: ?InputState, + navigation: AppNavigationProp, + viewerID: ?string, + chatContext: ?ChatContextType, + reactionMessageLocalID: ?string, ) { const messageID = route.params.item.messageInfo.id; invariant(messageID, 'messageID should be set'); @@ -25,6 +31,8 @@ const threadID = route.params.item.threadInfo.id; invariant(threadID, 'threadID should be set'); + invariant(reactionMessageLocalID, 'reactionMessageLocalID should be set'); + const reactionInput = '👍'; const viewerReacted = route.params.item.reactions.get(reactionInput) ?.viewerReacted; @@ -33,6 +41,7 @@ sendReaction( messageID, + reactionMessageLocalID, threadID, reactionInput, action, @@ -43,6 +52,7 @@ function sendReaction( messageID: string, + localID: string, threadID: string, reaction: string, action: 'add_reaction' | 'remove_reaction', @@ -55,6 +65,7 @@ try { const result = await callSendReactionMessage({ threadID, + localID, targetMessageID: messageID, reaction, action, diff --git a/native/navigation/tooltip.react.js b/native/navigation/tooltip.react.js --- a/native/navigation/tooltip.react.js +++ b/native/navigation/tooltip.react.js @@ -28,6 +28,7 @@ type ServerCallState, serverCallStateSelector, } from 'lib/selectors/server-calls'; +import { localIDPrefix } from 'lib/shared/message-utils'; import type { Dispatch } from 'lib/types/redux-types'; import { createBoundServerCallsSelector, @@ -71,6 +72,7 @@ navigation: AppNavigationProp, viewerID: ?string, chatContext: ?ChatContextType, + reactionMessageLocalID: ?string, ) => mixed, }; type TooltipItemProps = { @@ -115,6 +117,7 @@ +dimensions: DimensionsInfo, +serverCallState: ServerCallState, +viewerID: ?string, + +nextReactionMessageLocalID: number, // Redux dispatch functions +dispatch: Dispatch, +dispatchActionPromise: DispatchActionPromise, @@ -406,6 +409,7 @@ dimensions, serverCallState, viewerID, + nextReactionMessageLocalID, dispatch, dispatchActionPromise, overlayContext, @@ -567,6 +571,11 @@ this.props.setHideTooltip(true); } + let reactionMessageLocalID; + if (entry.id === 'react') { + reactionMessageLocalID = `${localIDPrefix}${this.props.nextReactionMessageLocalID}`; + } + const dispatchFunctions = { dispatch: this.props.dispatch, dispatchActionPromise: this.props.dispatchActionPromise, @@ -579,6 +588,7 @@ this.props.navigation, this.props.viewerID, this.props.chatContext, + reactionMessageLocalID, ); }; @@ -716,6 +726,7 @@ const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, ); + const nextReactionMessageLocalID = useSelector(state => state.nextLocalID); const dispatch = useDispatch(); const dispatchActionPromise = useDispatchActionPromise(); const overlayContext = React.useContext(OverlayContext); @@ -749,6 +760,7 @@ dimensions={dimensions} serverCallState={serverCallState} viewerID={viewerID} + nextReactionMessageLocalID={nextReactionMessageLocalID} dispatch={dispatch} dispatchActionPromise={dispatchActionPromise} overlayContext={overlayContext}