Skip to content

Commit d9c1bf8

Browse files
committed
Merge branch 'develop' of github.com:GetStream/stream-chat-react-native into fix/gallery-issue
2 parents 529d286 + 6a2e96d commit d9c1bf8

File tree

21 files changed

+465
-109
lines changed

21 files changed

+465
-109
lines changed

package/src/components/AttachmentPicker/components/AttachmentTypePickerButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { AttachmentCommandPicker } from './AttachmentPickerContent';
99
import {
1010
useAttachmentPickerContext,
1111
useChannelContext,
12+
useMessageComposer,
1213
useMessageInputContext,
1314
useMessagesContext,
1415
useOwnCapabilitiesContext,
@@ -181,6 +182,7 @@ export const PollPickerButton = () => {
181182

182183
export const CommandsPickerButton = () => {
183184
const [showCommandsSheet, setShowCommandsSheet] = useState(false);
185+
const messageComposer = useMessageComposer();
184186
const { hasCommands } = useMessageInputContext();
185187
const { attachmentPickerStore, disableAttachmentPicker } = useAttachmentPickerContext();
186188
const { selectedPicker } = useAttachmentPickerState();
@@ -195,7 +197,7 @@ export const CommandsPickerButton = () => {
195197

196198
const onClose = useStableCallback(() => setShowCommandsSheet(false));
197199

198-
return hasCommands ? (
200+
return hasCommands && !messageComposer.editedMessage ? (
199201
<>
200202
<AttachmentTypePickerButton
201203
testID='commands-touchable'

package/src/components/AutoCompleteInput/AutoCompleteSuggestionHeader.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { StyleSheet, Text, View } from 'react-native';
33

44
import { useTheme } from '../../contexts/themeContext/ThemeContext';
55

6-
import { Lightning } from '../../icons/Lightning';
76
import { Smile } from '../../icons/Smile';
7+
import { primitives } from '../../theme';
88

99
export type AutoCompleteSuggestionHeaderProps = {
1010
queryText?: string;
@@ -14,7 +14,7 @@ export type AutoCompleteSuggestionHeaderProps = {
1414
export const CommandsHeader: React.FC<AutoCompleteSuggestionHeaderProps> = () => {
1515
const {
1616
theme: {
17-
colors: { accent_blue, grey },
17+
semantics,
1818
messageInput: {
1919
suggestions: {
2020
header: { container, title },
@@ -25,8 +25,10 @@ export const CommandsHeader: React.FC<AutoCompleteSuggestionHeaderProps> = () =>
2525

2626
return (
2727
<View style={[styles.container, container]}>
28-
<Lightning fill={accent_blue} size={32} />
29-
<Text style={[styles.title, { color: grey }, title]} testID='commands-header-title'>
28+
<Text
29+
style={[styles.title, { color: semantics.textTertiary }, title]}
30+
testID='commands-header-title'
31+
>
3032
{'Instant Commands'}
3133
</Text>
3234
</View>
@@ -107,7 +109,9 @@ const styles = StyleSheet.create({
107109
padding: 8,
108110
},
109111
title: {
110-
fontSize: 14,
112+
fontSize: primitives.typographyFontSizeSm,
113+
lineHeight: primitives.typographyLineHeightNormal,
114+
fontWeight: primitives.typographyFontWeightMedium,
111115
paddingLeft: 8,
112116
},
113117
});

package/src/components/AutoCompleteInput/AutoCompleteSuggestionItem.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { AutoCompleteSuggestionCommandIcon } from './AutoCompleteSuggestionComma
77

88
import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer';
99
import { useTheme } from '../../contexts/themeContext/ThemeContext';
10-
import { AtMentions } from '../../icons/AtMentions';
1110
import { primitives } from '../../theme';
1211
import type { Emoji } from '../../types/types';
1312

@@ -22,7 +21,7 @@ export const MentionSuggestionItem = (item: UserSuggestion) => {
2221
const { id, name, online } = item;
2322
const {
2423
theme: {
25-
colors: { accent_blue, black },
24+
colors: { black },
2625
messageInput: {
2726
suggestions: {
2827
mention: { column, container: mentionContainer, name: nameStyle },
@@ -40,7 +39,6 @@ export const MentionSuggestionItem = (item: UserSuggestion) => {
4039
{name || id}
4140
</Text>
4241
</View>
43-
<AtMentions pathFill={accent_blue} />
4442
</View>
4543
);
4644
};
@@ -203,8 +201,9 @@ const useStyles = () => {
203201
paddingVertical: primitives.spacingXs,
204202
},
205203
name: {
206-
fontSize: 14,
207-
fontWeight: 'bold',
204+
fontSize: primitives.typographyFontSizeMd,
205+
lineHeight: primitives.typographyLineHeightNormal,
206+
color: semantics.textPrimary,
208207
paddingBottom: 2,
209208
},
210209
tag: {

package/src/components/AutoCompleteInput/AutoCompleteSuggestionList.tsx

Lines changed: 46 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import React, { useCallback, useMemo } from 'react';
2-
import { FlatList, StyleSheet, View } from 'react-native';
2+
import { FlatList, StyleSheet } from 'react-native';
3+
4+
import Animated, { LinearTransition, ZoomIn, ZoomOut } from 'react-native-reanimated';
35

46
import { SearchSourceState, TextComposerState, TextComposerSuggestion } from 'stream-chat';
57

@@ -12,7 +14,7 @@ import { useTheme } from '../../contexts/themeContext/ThemeContext';
1214
import { useStableCallback } from '../../hooks';
1315
import { useStateStore } from '../../hooks/useStateStore';
1416

15-
export const DEFAULT_LIST_HEIGHT = 200;
17+
export const DEFAULT_LIST_HEIGHT = 208;
1618

1719
export type AutoCompleteSuggestionListProps = Partial<
1820
Pick<MessageInputContextValue, 'AutoCompleteSuggestionHeader' | 'AutoCompleteSuggestionItem'>
@@ -63,10 +65,10 @@ export const AutoCompleteSuggestionList = ({
6365
colors: { black, white },
6466
messageInput: {
6567
container: { maxHeight },
66-
suggestionsListContainer: { flatlist },
6768
},
6869
},
6970
} = useTheme();
71+
const styles = useStyles();
7072

7173
const renderItem = useCallback(
7274
({ item }: { item: TextComposerSuggestion }) => {
@@ -90,7 +92,12 @@ export const AutoCompleteSuggestionList = ({
9092
}
9193

9294
return (
93-
<View style={[styles.container]}>
95+
<Animated.View
96+
entering={ZoomIn.duration(200)}
97+
exiting={ZoomOut.duration(200)}
98+
layout={LinearTransition.duration(200)}
99+
style={styles.container}
100+
>
94101
<FlatList
95102
data={items}
96103
keyboardShouldPersistTaps='always'
@@ -99,33 +106,47 @@ export const AutoCompleteSuggestionList = ({
99106
onEndReached={loadMore}
100107
onEndReachedThreshold={0.1}
101108
renderItem={renderItem}
102-
style={[
103-
styles.flatlist,
104-
flatlist,
105-
{ backgroundColor: white, maxHeight, shadowColor: black },
106-
]}
109+
style={[styles.flatlist, { backgroundColor: white, maxHeight, shadowColor: black }]}
107110
testID={'auto-complete-suggestion-list'}
108111
/>
109-
</View>
112+
</Animated.View>
110113
);
111114
};
112115

113-
const styles = StyleSheet.create({
114-
container: {
115-
maxHeight: DEFAULT_LIST_HEIGHT,
116-
},
117-
flatlist: {
118-
borderRadius: 8,
119-
elevation: 3,
120-
marginHorizontal: 8,
121-
shadowOffset: {
122-
height: 1,
123-
width: 0,
116+
const useStyles = () => {
117+
const {
118+
theme: {
119+
semantics,
120+
messageInput: {
121+
suggestionsListContainer: { flatlist },
122+
},
124123
},
125-
shadowOpacity: 0.22,
126-
shadowRadius: 2.22,
127-
},
128-
});
124+
} = useTheme();
125+
return useMemo(
126+
() =>
127+
StyleSheet.create({
128+
container: {
129+
maxHeight: DEFAULT_LIST_HEIGHT,
130+
backgroundColor: semantics.composerBg,
131+
borderTopWidth: 1,
132+
borderColor: semantics.borderCoreDefault,
133+
},
134+
flatlist: {
135+
borderRadius: 8,
136+
elevation: 3,
137+
marginHorizontal: 8,
138+
shadowOffset: {
139+
height: 1,
140+
width: 0,
141+
},
142+
shadowOpacity: 0.22,
143+
shadowRadius: 2.22,
144+
...flatlist,
145+
},
146+
}),
147+
[semantics, flatlist],
148+
);
149+
};
129150

130151
AutoCompleteSuggestionList.displayName =
131152
'AutoCompleteSuggestionList{messageInput{suggestions{List}}}';

package/src/components/Message/MessageSimple/MessageContent.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ const MessageContentWithContext = (props: MessageContentPropsWithContext) => {
310310
key={`quoted_reply_${messageContentOrderIndex}`}
311311
style={[styles.replyContainer, replyContainer]}
312312
>
313-
<Reply styles={replyStyles} />
313+
<Reply mode='reply' styles={replyStyles} />
314314
</View>
315315
)
316316
);

package/src/components/Message/utils/messageActions.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { MessagesContextValue } from '../../../contexts/messagesContext/Mes
33
import type { OwnCapabilitiesContextValue } from '../../../contexts/ownCapabilitiesContext/OwnCapabilitiesContext';
44
import { isClipboardAvailable } from '../../../native';
55

6+
import { FileTypes } from '../../../types/types';
67
import type { MessageActionType } from '../../MessageMenu/MessageActionListItem';
78

89
export type MessageActionsParams = {
@@ -53,6 +54,9 @@ export const messageActions = ({
5354
threadReply,
5455
unpinMessage,
5556
}: MessageActionsParams) => {
57+
const messageHasGiphyOrImgur = message.attachments?.some(
58+
(attachment) => attachment.type === FileTypes.Giphy || attachment.type === FileTypes.Imgur,
59+
);
5660
if (showMessageReactions) {
5761
return [];
5862
}
@@ -72,8 +76,10 @@ export const messageActions = ({
7276
}
7377

7478
if (
75-
(isMyMessage && ownCapabilities.updateOwnMessage) ||
76-
(!isMyMessage && ownCapabilities.updateAnyMessage)
79+
((isMyMessage && ownCapabilities.updateOwnMessage) ||
80+
(!isMyMessage && ownCapabilities.updateAnyMessage)) &&
81+
!messageHasGiphyOrImgur &&
82+
!message.poll_id
7783
) {
7884
actions.push(editMessage);
7985
}

package/src/components/MessageInput/MessageInput.tsx

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import { Modal, StyleSheet, TextInput, TextInputProps, View } from 'react-native
44
import { GestureHandlerRootView } from 'react-native-gesture-handler';
55
import Animated, {
66
Extrapolation,
7-
FadeIn,
8-
FadeOut,
97
interpolate,
108
LinearTransition,
119
useAnimatedStyle,
@@ -133,6 +131,7 @@ const useStyles = () => {
133131
shadowRadius: 12,
134132
},
135133
suggestionsListContainer: {
134+
backgroundColor: semantics.composerBg,
136135
position: 'absolute',
137136
width: '100%',
138137
},
@@ -454,14 +453,9 @@ const MessageInputWithContext = (props: MessageInputPropsWithContext) => {
454453
<MessageComposerTrailingView />
455454
)}
456455

457-
<Animated.View
458-
entering={FadeIn.duration(200)}
459-
exiting={FadeOut.duration(200)}
460-
layout={LinearTransition.duration(200)}
461-
style={[styles.suggestionsListContainer, { bottom: height }, suggestionListContainer]}
462-
>
456+
<View style={[styles.suggestionsListContainer, { bottom: height }, suggestionListContainer]}>
463457
<AutoCompleteSuggestionList />
464-
</Animated.View>
458+
</View>
465459

466460
{showPollCreationDialog ? (
467461
<View style={styles.pollModalWrapper}>

package/src/components/MessageInput/MessageInputHeaderView.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useCallback } from 'react';
22
import { StyleSheet } from 'react-native';
33

44
import Animated, { FadeIn, FadeOut, LinearTransition } from 'react-native-reanimated';
@@ -36,6 +36,9 @@ export const MessageInputHeaderView = () => {
3636
idleRecordingStateSelector,
3737
);
3838
const hasAttachments = useHasAttachments();
39+
const onDismissReply = useCallback(() => {
40+
messageComposer.setQuotedMessage(null);
41+
}, [messageComposer]);
3942

4043
return isRecordingStateIdle ? (
4144
<Animated.View
@@ -62,7 +65,7 @@ export const MessageInputHeaderView = () => {
6265
) : null}
6366
{quotedMessage ? (
6467
<Animated.View entering={FadeIn.duration(200)} exiting={FadeOut.duration(200)}>
65-
<Reply mode='reply' />
68+
<Reply onDismiss={editing ? undefined : onDismissReply} mode='reply' />
6669
</Animated.View>
6770
) : null}
6871
<AttachmentUploadPreviewList />

package/src/components/MessageInput/MessageInputLeadingView.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
1-
import React from 'react';
1+
import React, { useEffect } from 'react';
22
import { StyleSheet, View } from 'react-native';
33

4+
import { AttachmentManagerState } from 'stream-chat';
5+
46
import { textComposerStateSelector } from './utils/messageComposerSelectors';
57

68
import { useMessageComposer } from '../../contexts/messageInputContext/hooks/useMessageComposer';
79
import { useStateStore } from '../../hooks/useStateStore';
810
import { primitives } from '../../theme';
911
import { GiphyChip } from '../ui/GiphyChip';
1012

13+
const hasAttachmentsSelector = (nextState: AttachmentManagerState) => ({
14+
hasAttachments: nextState.attachments?.length > 0,
15+
});
16+
1117
export const MessageInputLeadingView = () => {
1218
const messageComposer = useMessageComposer();
1319
const { textComposer } = messageComposer;
20+
// TODO: V9: This needs to come from the LLC.
21+
const { hasAttachments } = useStateStore(
22+
messageComposer.attachmentManager.state,
23+
hasAttachmentsSelector,
24+
);
1425
const { command } = useStateStore(textComposer.state, textComposerStateSelector);
1526

16-
return command ? (
27+
useEffect(() => {
28+
if (hasAttachments) {
29+
textComposer.clearCommand();
30+
}
31+
}, [textComposer, hasAttachments]);
32+
33+
return command && !hasAttachments ? (
1734
<View style={styles.giphyContainer}>
1835
<GiphyChip />
1936
</View>

package/src/components/MessageInput/components/AudioRecorder/AudioRecordingButton.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,14 @@ export const AudioRecordingButtonWithContext = (props: AudioRecordingButtonProps
151151
});
152152

153153
const onTouchGestureEnd = useStableCallback(() => {
154+
if (cancellableDuration) {
155+
onEarlyReleaseHandler();
156+
return;
157+
}
154158
if (status === 'recording') {
155-
if (cancellableDuration) {
156-
onEarlyReleaseHandler();
157-
} else {
158-
uploadVoiceRecording(asyncMessagesMultiSendEnabled);
159-
}
159+
uploadVoiceRecording(asyncMessagesMultiSendEnabled);
160+
} else {
161+
resetAudioRecording();
160162
}
161163
});
162164

0 commit comments

Comments
 (0)