Skip to content

Commit e11dc78

Browse files
committed
fix: command button resolution
1 parent 9ece258 commit e11dc78

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

package/src/components/MessageInput/MessageInputLeadingView.tsx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,25 @@ import { StyleSheet } from 'react-native';
33

44
import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated';
55

6-
import { AttachmentManagerState } from 'stream-chat';
7-
86
import { textComposerStateSelector } from './utils/messageComposerSelectors';
97

108
import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer';
119
import { useStateStore } from '../../hooks/useStateStore';
1210
import { primitives } from '../../theme';
1311
import { GiphyChip } from '../ui/GiphyChip';
1412

15-
const hasAttachmentsSelector = (nextState: AttachmentManagerState) => ({
16-
hasAttachments: nextState.attachments?.length > 0,
17-
});
18-
1913
export const MessageInputLeadingView = () => {
2014
const messageComposer = useMessageComposer();
21-
const { textComposer } = messageComposer;
22-
// TODO: V9: This needs to come from the LLC.
23-
const { hasAttachments } = useStateStore(
24-
messageComposer.attachmentManager.state,
25-
hasAttachmentsSelector,
26-
);
15+
const { textComposer, attachmentManager } = messageComposer;
2716
const { command } = useStateStore(textComposer.state, textComposerStateSelector);
2817

2918
useEffect(() => {
30-
if (hasAttachments) {
19+
if (attachmentManager.state.getLatestValue().attachments.length > 0) {
3120
textComposer.clearCommand();
3221
}
33-
}, [textComposer, hasAttachments]);
22+
}, [textComposer, attachmentManager]);
3423

35-
return command && !hasAttachments ? (
24+
return command ? (
3625
<Animated.View
3726
entering={ZoomIn.duration(200)}
3827
exiting={ZoomOut.duration(200)}

0 commit comments

Comments
 (0)