-
Notifications
You must be signed in to change notification settings - Fork 375
Expand file tree
/
Copy pathMessageInputLeadingView.tsx
More file actions
50 lines (41 loc) · 1.48 KB
/
MessageInputLeadingView.tsx
File metadata and controls
50 lines (41 loc) · 1.48 KB
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
import React, { useEffect } from 'react';
import { StyleSheet } from 'react-native';
import Animated, { ZoomIn, ZoomOut } from 'react-native-reanimated';
import { AttachmentManagerState } from 'stream-chat';
import { textComposerStateSelector } from './utils/messageComposerSelectors';
import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer';
import { useStateStore } from '../../hooks/useStateStore';
import { primitives } from '../../theme';
import { GiphyChip } from '../ui/GiphyChip';
const hasAttachmentsSelector = (nextState: AttachmentManagerState) => ({
hasAttachments: nextState.attachments?.length > 0,
});
export const MessageInputLeadingView = () => {
const messageComposer = useMessageComposer();
const { textComposer } = messageComposer;
// TODO: V9: This needs to come from the LLC.
const { hasAttachments } = useStateStore(
messageComposer.attachmentManager.state,
hasAttachmentsSelector,
);
const { command } = useStateStore(textComposer.state, textComposerStateSelector);
useEffect(() => {
if (hasAttachments) {
textComposer.clearCommand();
}
}, [textComposer, hasAttachments]);
return command && !hasAttachments ? (
<Animated.View
entering={ZoomIn.duration(200)}
exiting={ZoomOut.duration(200)}
style={styles.giphyContainer}
>
<GiphyChip />
</Animated.View>
) : null;
};
const styles = StyleSheet.create({
giphyContainer: {
padding: primitives.spacingXs,
},
});