diff --git a/native/chat/chat-context-provider.react.js b/native/chat/chat-context-provider.react.js --- a/native/chat/chat-context-provider.react.js +++ b/native/chat/chat-context-provider.react.js @@ -126,11 +126,6 @@ sidebarAnimationType, setSidebarAnimationType, ] = React.useState('move_source_message'); - const setSidebarAnimationTypeCallback = React.useCallback( - (animationType: SidebarAnimationType) => - setSidebarAnimationType(animationType), - [], - ); const contextValue = React.useMemo( () => ({ @@ -141,14 +136,13 @@ deleteChatInputBarHeight, chatInputBarHeights: chatInputBarHeights.current, sidebarAnimationType, - setSidebarAnimationType: setSidebarAnimationTypeCallback, + setSidebarAnimationType, }), [ currentTransitionSidebarSourceID, deleteChatInputBarHeight, registerMeasurer, setChatInputBarHeight, - setSidebarAnimationTypeCallback, sidebarAnimationType, ], ); diff --git a/native/chat/utils.js b/native/chat/utils.js --- a/native/chat/utils.js +++ b/native/chat/utils.js @@ -219,31 +219,25 @@ const viewerID = useSelector( state => state.currentUserInfo && state.currentUserInfo.id, ); - const sidebarThreadInfo = React.useMemo(() => { - return getSidebarThreadInfo(sourceMessage, viewerID); - }, [sourceMessage, viewerID]); + const sidebarThreadInfo = React.useMemo( + () => getSidebarThreadInfo(sourceMessage, viewerID), + [sourceMessage, viewerID], + ); const currentInputBarHeight = chatInputBarHeights.get(sourceMessage.threadInfo.id) ?? 0; const keyboardState = React.useContext(KeyboardContext); - const viewerIsSidebarMember = viewerIsMember(sidebarThreadInfo); + + const newSidebarAnimationType = + !currentInputBarHeight || + !targetInputBarHeight || + keyboardState?.keyboardShowing || + !viewerIsMember(sidebarThreadInfo) + ? 'fade_source_message' + : 'move_source_message'; React.useEffect(() => { - const newSidebarAnimationType = - !currentInputBarHeight || - !targetInputBarHeight || - keyboardState?.keyboardShowing || - !viewerIsSidebarMember - ? 'fade_source_message' - : 'move_source_message'; setSidebarAnimationType(newSidebarAnimationType); - }, [ - currentInputBarHeight, - keyboardState?.keyboardShowing, - setSidebarAnimationType, - sidebarThreadInfo, - targetInputBarHeight, - viewerIsSidebarMember, - ]); + }, [setSidebarAnimationType, newSidebarAnimationType]); const { position: targetPosition,