stream-chat-react-native-core 3.8.3-next.1 → 3.9.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Attachment/Gallery.js +21 -9
- package/lib/commonjs/components/Attachment/Gallery.js.map +1 -1
- package/lib/commonjs/components/Channel/Channel.js +52 -30
- package/lib/commonjs/components/Channel/Channel.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js +4 -0
- package/lib/commonjs/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js +4 -0
- package/lib/commonjs/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js +9 -6
- package/lib/commonjs/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js +28 -23
- package/lib/commonjs/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/commonjs/components/MessageList/MessageList.js +40 -31
- package/lib/commonjs/components/MessageList/MessageList.js.map +1 -1
- package/lib/commonjs/components/MessageList/hooks/useMessageList.js +1 -1
- package/lib/commonjs/components/MessageList/hooks/useMessageList.js.map +1 -1
- package/lib/commonjs/components/MessageList/utils/getGroupStyles.js +1 -5
- package/lib/commonjs/components/MessageList/utils/getGroupStyles.js.map +1 -1
- package/lib/commonjs/contexts/channelContext/ChannelContext.js +2 -2
- package/lib/commonjs/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/commonjs/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/commonjs/version.json +1 -1
- package/lib/module/components/Attachment/Gallery.js +21 -9
- package/lib/module/components/Attachment/Gallery.js.map +1 -1
- package/lib/module/components/Channel/Channel.js +52 -30
- package/lib/module/components/Channel/Channel.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateChannelContext.js +4 -0
- package/lib/module/components/Channel/hooks/useCreateChannelContext.js.map +1 -1
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js +4 -0
- package/lib/module/components/Channel/hooks/useCreateMessagesContext.js.map +1 -1
- package/lib/module/components/Message/MessageSimple/MessageSimple.js +9 -6
- package/lib/module/components/Message/MessageSimple/MessageSimple.js.map +1 -1
- package/lib/module/components/MessageInput/FileUploadPreview.js +28 -23
- package/lib/module/components/MessageInput/FileUploadPreview.js.map +1 -1
- package/lib/module/components/MessageList/MessageList.js +40 -31
- package/lib/module/components/MessageList/MessageList.js.map +1 -1
- package/lib/module/components/MessageList/hooks/useMessageList.js +1 -1
- package/lib/module/components/MessageList/hooks/useMessageList.js.map +1 -1
- package/lib/module/components/MessageList/utils/getGroupStyles.js +1 -5
- package/lib/module/components/MessageList/utils/getGroupStyles.js.map +1 -1
- package/lib/module/contexts/channelContext/ChannelContext.js +2 -2
- package/lib/module/contexts/channelContext/ChannelContext.js.map +1 -1
- package/lib/module/contexts/messagesContext/MessagesContext.js +2 -2
- package/lib/module/contexts/messagesContext/MessagesContext.js.map +1 -1
- package/lib/module/version.json +1 -1
- package/lib/typescript/components/Attachment/Gallery.d.ts +1 -1
- package/lib/typescript/components/Channel/Channel.d.ts +3 -1
- package/lib/typescript/components/Channel/hooks/useCreateChannelContext.d.ts +1 -1
- package/lib/typescript/components/Channel/hooks/useCreateMessagesContext.d.ts +4 -2
- package/lib/typescript/components/Message/MessageSimple/MessageSimple.d.ts +1 -1
- package/lib/typescript/components/MessageList/MessageList.d.ts +1 -1
- package/lib/typescript/contexts/channelContext/ChannelContext.d.ts +3 -1
- package/lib/typescript/contexts/messagesContext/MessagesContext.d.ts +3 -1
- package/package.json +1 -1
- package/src/components/Attachment/Gallery.tsx +20 -5
- package/src/components/Channel/Channel.tsx +124 -67
- package/src/components/Channel/hooks/useCreateChannelContext.ts +4 -0
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +4 -0
- package/src/components/Message/MessageSimple/MessageSimple.tsx +9 -3
- package/src/components/MessageInput/FileUploadPreview.tsx +68 -58
- package/src/components/MessageInput/__tests__/__snapshots__/FileUploadPreview.test.js.snap +778 -730
- package/src/components/MessageList/MessageList.tsx +52 -27
- package/src/components/MessageList/hooks/useMessageList.ts +1 -1
- package/src/components/MessageList/utils/getGroupStyles.ts +3 -8
- package/src/contexts/channelContext/ChannelContext.tsx +2 -0
- package/src/contexts/messagesContext/MessagesContext.tsx +2 -0
- package/src/version.json +1 -1
- package/lib/commonjs/components/Channel/utils/debounce.js +0 -20
- package/lib/commonjs/components/Channel/utils/debounce.js.map +0 -1
- package/lib/commonjs/components/Channel/utils/throttle.js +0 -20
- package/lib/commonjs/components/Channel/utils/throttle.js.map +0 -1
- package/lib/module/components/Channel/utils/debounce.js +0 -20
- package/lib/module/components/Channel/utils/debounce.js.map +0 -1
- package/lib/module/components/Channel/utils/throttle.js +0 -20
- package/lib/module/components/Channel/utils/throttle.js.map +0 -1
- package/lib/typescript/components/Channel/utils/debounce.d.ts +0 -2
- package/lib/typescript/components/Channel/utils/throttle.d.ts +0 -2
- package/src/components/Channel/utils/debounce.ts +0 -12
- package/src/components/Channel/utils/throttle.ts +0 -12
|
@@ -98,19 +98,23 @@ export type GalleryPropsWithContext<
|
|
|
98
98
|
Me extends UnknownType = DefaultMessageType,
|
|
99
99
|
Re extends UnknownType = DefaultReactionType,
|
|
100
100
|
Us extends UnknownType = DefaultUserType,
|
|
101
|
-
> = Pick<ImageGalleryContextValue, 'setImage'> &
|
|
101
|
+
> = Pick<ImageGalleryContextValue, 'setImage' | 'setImages'> &
|
|
102
102
|
Pick<
|
|
103
103
|
MessageContextValue<At, Ch, Co, Ev, Me, Re, Us>,
|
|
104
104
|
| 'alignment'
|
|
105
105
|
| 'groupStyles'
|
|
106
106
|
| 'images'
|
|
107
|
+
| 'message'
|
|
107
108
|
| 'onLongPress'
|
|
108
109
|
| 'onPress'
|
|
109
110
|
| 'onPressIn'
|
|
110
111
|
| 'preventPress'
|
|
111
112
|
| 'threadList'
|
|
112
113
|
> &
|
|
113
|
-
Pick<
|
|
114
|
+
Pick<
|
|
115
|
+
MessagesContextValue<At, Ch, Co, Ev, Me, Re, Us>,
|
|
116
|
+
'additionalTouchableProps' | 'legacyImageViewerSwipeBehaviour'
|
|
117
|
+
> &
|
|
114
118
|
Pick<OverlayContextValue, 'setBlurType' | 'setOverlay'> & {
|
|
115
119
|
hasThreadReplies?: boolean;
|
|
116
120
|
messageId?: string;
|
|
@@ -134,6 +138,8 @@ const GalleryWithContext = <
|
|
|
134
138
|
groupStyles,
|
|
135
139
|
hasThreadReplies,
|
|
136
140
|
images,
|
|
141
|
+
legacyImageViewerSwipeBehaviour,
|
|
142
|
+
message,
|
|
137
143
|
messageId,
|
|
138
144
|
messageText,
|
|
139
145
|
onLongPress,
|
|
@@ -142,6 +148,7 @@ const GalleryWithContext = <
|
|
|
142
148
|
preventPress,
|
|
143
149
|
setBlurType,
|
|
144
150
|
setImage,
|
|
151
|
+
setImages,
|
|
145
152
|
setOverlay,
|
|
146
153
|
threadList,
|
|
147
154
|
} = props;
|
|
@@ -217,6 +224,9 @@ const GalleryWithContext = <
|
|
|
217
224
|
>
|
|
218
225
|
{column.map(({ height, url }, rowIndex) => {
|
|
219
226
|
const defaultOnPress = () => {
|
|
227
|
+
if (!legacyImageViewerSwipeBehaviour) {
|
|
228
|
+
setImages([message]);
|
|
229
|
+
}
|
|
220
230
|
setImage({ messageId, url });
|
|
221
231
|
setBlurType(blurType);
|
|
222
232
|
setOverlay('gallery');
|
|
@@ -413,7 +423,7 @@ export const Gallery = <
|
|
|
413
423
|
threadList: propThreadList,
|
|
414
424
|
} = props;
|
|
415
425
|
|
|
416
|
-
const { setImage: contextSetImage } = useImageGalleryContext();
|
|
426
|
+
const { setImage: contextSetImage, setImages } = useImageGalleryContext();
|
|
417
427
|
const {
|
|
418
428
|
alignment: contextAlignment,
|
|
419
429
|
groupStyles: contextGroupStyles,
|
|
@@ -425,8 +435,10 @@ export const Gallery = <
|
|
|
425
435
|
preventPress: contextPreventPress,
|
|
426
436
|
threadList: contextThreadList,
|
|
427
437
|
} = useMessageContext<At, Ch, Co, Ev, Me, Re, Us>();
|
|
428
|
-
const {
|
|
429
|
-
|
|
438
|
+
const {
|
|
439
|
+
additionalTouchableProps: contextAdditionalTouchableProps,
|
|
440
|
+
legacyImageViewerSwipeBehaviour,
|
|
441
|
+
} = useMessagesContext<At, Ch, Co, Ev, Me, Re, Us>();
|
|
430
442
|
const { setBlurType: contextSetBlurType, setOverlay: contextSetOverlay } = useOverlayContext();
|
|
431
443
|
|
|
432
444
|
const images = propImages || contextImages;
|
|
@@ -454,6 +466,8 @@ export const Gallery = <
|
|
|
454
466
|
groupStyles,
|
|
455
467
|
hasThreadReplies: hasThreadReplies || !!message?.reply_count,
|
|
456
468
|
images,
|
|
469
|
+
legacyImageViewerSwipeBehaviour,
|
|
470
|
+
message,
|
|
457
471
|
messageId: messageId || message?.id,
|
|
458
472
|
messageText: messageText || message?.text,
|
|
459
473
|
onLongPress,
|
|
@@ -462,6 +476,7 @@ export const Gallery = <
|
|
|
462
476
|
preventPress,
|
|
463
477
|
setBlurType,
|
|
464
478
|
setImage,
|
|
479
|
+
setImages,
|
|
465
480
|
setOverlay,
|
|
466
481
|
threadList,
|
|
467
482
|
}}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import React, { PropsWithChildren, useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import React, { PropsWithChildren, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { KeyboardAvoidingViewProps, StyleSheet, Text, View } from 'react-native';
|
|
3
|
+
import debounce from 'lodash/debounce';
|
|
4
|
+
import throttle from 'lodash/throttle';
|
|
3
5
|
import {
|
|
4
6
|
ChannelState,
|
|
5
7
|
Channel as ChannelType,
|
|
@@ -21,8 +23,6 @@ import { useCreatePaginatedMessageListContext } from './hooks/useCreatePaginated
|
|
|
21
23
|
import { useCreateThreadContext } from './hooks/useCreateThreadContext';
|
|
22
24
|
import { useCreateTypingContext } from './hooks/useCreateTypingContext';
|
|
23
25
|
import { useTargetedMessage } from './hooks/useTargetedMessage';
|
|
24
|
-
import { heavyDebounce } from './utils/debounce';
|
|
25
|
-
import { lightThrottle } from './utils/throttle';
|
|
26
26
|
|
|
27
27
|
import { Attachment as AttachmentDefault } from '../Attachment/Attachment';
|
|
28
28
|
import { AttachmentActions as AttachmentActionsDefault } from '../Attachment/AttachmentActions';
|
|
@@ -157,6 +157,17 @@ export const reactionData: ReactionData[] = [
|
|
|
157
157
|
*/
|
|
158
158
|
const scrollToFirstUnreadThreshold = 4;
|
|
159
159
|
|
|
160
|
+
const defaultThrottleInterval = 500;
|
|
161
|
+
const defaultDebounceInterval = 500;
|
|
162
|
+
const throttleOptions = {
|
|
163
|
+
leading: false,
|
|
164
|
+
trailing: true,
|
|
165
|
+
};
|
|
166
|
+
const debounceOptions = {
|
|
167
|
+
leading: true,
|
|
168
|
+
trailing: true,
|
|
169
|
+
};
|
|
170
|
+
|
|
160
171
|
/**
|
|
161
172
|
* Number of unread messages to show in first frame, when channel loads at first
|
|
162
173
|
* unread message. Only applicable if unread count > scrollToFirstUnreadThreshold.
|
|
@@ -176,8 +187,10 @@ export type ChannelPropsWithContext<
|
|
|
176
187
|
ChannelContextValue<At, Ch, Co, Ev, Me, Re, Us>,
|
|
177
188
|
| 'channel'
|
|
178
189
|
| 'EmptyStateIndicator'
|
|
190
|
+
| 'enableMessageGroupingByUser'
|
|
179
191
|
| 'enforceUniqueReaction'
|
|
180
192
|
| 'giphyEnabled'
|
|
193
|
+
| 'hideStickyDateHeader'
|
|
181
194
|
| 'hideDateSeparators'
|
|
182
195
|
| 'LoadingIndicator'
|
|
183
196
|
| 'maxTimeBetweenGroupedMessages'
|
|
@@ -349,6 +362,7 @@ export type ChannelPropsWithContext<
|
|
|
349
362
|
*/
|
|
350
363
|
KeyboardCompatibleView?: React.ComponentType<KeyboardAvoidingViewProps>;
|
|
351
364
|
keyboardVerticalOffset?: number;
|
|
365
|
+
legacyImageViewerSwipeBehaviour?: boolean;
|
|
352
366
|
/**
|
|
353
367
|
* Custom loading error indicator to override the Stream default
|
|
354
368
|
*/
|
|
@@ -359,6 +373,7 @@ export type ChannelPropsWithContext<
|
|
|
359
373
|
quotedRepliesEnabled?: boolean;
|
|
360
374
|
reactionsEnabled?: boolean;
|
|
361
375
|
readEventsEnabled?: boolean;
|
|
376
|
+
stateUpdateThrottleInterval?: number;
|
|
362
377
|
threadRepliesEnabled?: boolean;
|
|
363
378
|
typingEventsEnabled?: boolean;
|
|
364
379
|
uploadsEnabled?: boolean;
|
|
@@ -411,6 +426,7 @@ const ChannelWithContext = <
|
|
|
411
426
|
doUpdateMessageRequest,
|
|
412
427
|
editMessage: editMessageProp,
|
|
413
428
|
EmptyStateIndicator = EmptyStateIndicatorDefault,
|
|
429
|
+
enableMessageGroupingByUser = true,
|
|
414
430
|
enforceUniqueReaction = false,
|
|
415
431
|
FileAttachment = FileAttachmentDefault,
|
|
416
432
|
FileAttachmentIcon = FileIconDefault,
|
|
@@ -438,6 +454,7 @@ const ChannelWithContext = <
|
|
|
438
454
|
hasFilePicker = true,
|
|
439
455
|
hasImagePicker = true,
|
|
440
456
|
hideDateSeparators = false,
|
|
457
|
+
hideStickyDateHeader = false,
|
|
441
458
|
ImageUploadPreview = ImageUploadPreviewDefault,
|
|
442
459
|
initialScrollToFirstUnreadMessage = false,
|
|
443
460
|
initialValue,
|
|
@@ -448,6 +465,7 @@ const ChannelWithContext = <
|
|
|
448
465
|
keyboardBehavior,
|
|
449
466
|
KeyboardCompatibleView = KeyboardCompatibleViewDefault,
|
|
450
467
|
keyboardVerticalOffset,
|
|
468
|
+
legacyImageViewerSwipeBehaviour = true,
|
|
451
469
|
LoadingErrorIndicator = LoadingErrorIndicatorDefault,
|
|
452
470
|
LoadingIndicator = LoadingIndicatorDefault,
|
|
453
471
|
loadingMore: loadingMoreProp,
|
|
@@ -501,6 +519,7 @@ const ChannelWithContext = <
|
|
|
501
519
|
sendImageAsync = false,
|
|
502
520
|
setInputRef,
|
|
503
521
|
ShowThreadMessageInChannelButton = ShowThreadMessageInChannelButtonDefault,
|
|
522
|
+
stateUpdateThrottleInterval = defaultThrottleInterval,
|
|
504
523
|
StickyHeader,
|
|
505
524
|
supportedReactions = reactionData,
|
|
506
525
|
t,
|
|
@@ -645,43 +664,65 @@ const ChannelWithContext = <
|
|
|
645
664
|
/**
|
|
646
665
|
* CHANNEL METHODS
|
|
647
666
|
*/
|
|
648
|
-
const markRead: ChannelContextValue<At, Ch, Co, Ev, Me, Re, Us>['markRead'] =
|
|
649
|
-
(
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
if (doMarkReadRequest) {
|
|
655
|
-
doMarkReadRequest(channel);
|
|
656
|
-
} else {
|
|
657
|
-
logChatPromiseExecution(channel.markRead(), 'mark read');
|
|
658
|
-
}
|
|
659
|
-
},
|
|
660
|
-
);
|
|
661
|
-
|
|
662
|
-
const copyTypingState = lightThrottle(() => {
|
|
663
|
-
if (channel) {
|
|
664
|
-
setTyping({ ...channel.state.typing });
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
|
|
668
|
-
const copyReadState = lightThrottle(() => {
|
|
669
|
-
if (channel) {
|
|
670
|
-
setRead({ ...channel.state.read });
|
|
671
|
-
}
|
|
672
|
-
});
|
|
667
|
+
const markRead: ChannelContextValue<At, Ch, Co, Ev, Me, Re, Us>['markRead'] = useRef(
|
|
668
|
+
throttle(
|
|
669
|
+
() => {
|
|
670
|
+
if (channel?.disconnected || !channel?.getConfig?.()?.read_events) {
|
|
671
|
+
return;
|
|
672
|
+
}
|
|
673
673
|
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
674
|
+
if (doMarkReadRequest) {
|
|
675
|
+
doMarkReadRequest(channel);
|
|
676
|
+
} else {
|
|
677
|
+
logChatPromiseExecution(channel.markRead(), 'mark read');
|
|
678
|
+
}
|
|
679
|
+
},
|
|
680
|
+
defaultThrottleInterval,
|
|
681
|
+
throttleOptions,
|
|
682
|
+
),
|
|
683
|
+
).current;
|
|
684
|
+
|
|
685
|
+
const copyTypingState = useRef(
|
|
686
|
+
throttle(
|
|
687
|
+
() => {
|
|
688
|
+
if (channel) {
|
|
689
|
+
setTyping({ ...channel.state.typing });
|
|
690
|
+
}
|
|
691
|
+
},
|
|
692
|
+
stateUpdateThrottleInterval,
|
|
693
|
+
throttleOptions,
|
|
694
|
+
),
|
|
695
|
+
).current;
|
|
696
|
+
|
|
697
|
+
const copyReadState = useRef(
|
|
698
|
+
throttle(
|
|
699
|
+
() => {
|
|
700
|
+
if (channel) {
|
|
701
|
+
setRead({ ...channel.state.read });
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
stateUpdateThrottleInterval,
|
|
705
|
+
throttleOptions,
|
|
706
|
+
),
|
|
707
|
+
).current;
|
|
708
|
+
|
|
709
|
+
const copyChannelState = useRef(
|
|
710
|
+
throttle(
|
|
711
|
+
() => {
|
|
712
|
+
setLoading(false);
|
|
713
|
+
if (channel) {
|
|
714
|
+
setMembers({ ...channel.state.members });
|
|
715
|
+
setMessages([...channel.state.messages]);
|
|
716
|
+
setRead({ ...channel.state.read });
|
|
717
|
+
setTyping({ ...channel.state.typing });
|
|
718
|
+
setWatcherCount(channel.state.watcher_count);
|
|
719
|
+
setWatchers({ ...channel.state.watchers });
|
|
720
|
+
}
|
|
721
|
+
},
|
|
722
|
+
stateUpdateThrottleInterval,
|
|
723
|
+
throttleOptions,
|
|
724
|
+
),
|
|
725
|
+
).current;
|
|
685
726
|
|
|
686
727
|
const connectionRecoveredHandler = () => {
|
|
687
728
|
if (channel) {
|
|
@@ -1302,17 +1343,21 @@ const ChannelWithContext = <
|
|
|
1302
1343
|
};
|
|
1303
1344
|
|
|
1304
1345
|
// hard limit to prevent you from scrolling faster than 1 page per 2 seconds
|
|
1305
|
-
const loadMoreFinished =
|
|
1306
|
-
(
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1346
|
+
const loadMoreFinished = useRef(
|
|
1347
|
+
debounce(
|
|
1348
|
+
(
|
|
1349
|
+
updatedHasMore: boolean,
|
|
1350
|
+
newMessages: ChannelState<At, Ch, Co, Ev, Me, Re, Us>['messages'],
|
|
1351
|
+
) => {
|
|
1352
|
+
setLoadingMore(false);
|
|
1353
|
+
setError(false);
|
|
1354
|
+
setHasMore(updatedHasMore);
|
|
1355
|
+
setMessages(newMessages);
|
|
1356
|
+
},
|
|
1357
|
+
defaultDebounceInterval,
|
|
1358
|
+
debounceOptions,
|
|
1359
|
+
),
|
|
1360
|
+
).current;
|
|
1316
1361
|
|
|
1317
1362
|
const loadMore: PaginatedMessageListContextValue<At, Ch, Co, Ev, Me, Re, Us>['loadMore'] = async (
|
|
1318
1363
|
limit = 20,
|
|
@@ -1387,13 +1432,17 @@ const ChannelWithContext = <
|
|
|
1387
1432
|
};
|
|
1388
1433
|
|
|
1389
1434
|
// hard limit to prevent you from scrolling faster than 1 page per 2 seconds
|
|
1390
|
-
const loadMoreRecentFinished =
|
|
1391
|
-
(
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1435
|
+
const loadMoreRecentFinished = useRef(
|
|
1436
|
+
debounce(
|
|
1437
|
+
(newMessages: ChannelState<At, Ch, Co, Ev, Me, Re, Us>['messages']) => {
|
|
1438
|
+
setLoadingMoreRecent(false);
|
|
1439
|
+
setMessages(newMessages);
|
|
1440
|
+
setError(false);
|
|
1441
|
+
},
|
|
1442
|
+
defaultDebounceInterval,
|
|
1443
|
+
debounceOptions,
|
|
1444
|
+
),
|
|
1445
|
+
).current;
|
|
1397
1446
|
|
|
1398
1447
|
const editMessage: InputMessageInputContextValue<At, Ch, Co, Ev, Me, Re, Us>['editMessage'] = (
|
|
1399
1448
|
updatedMessage,
|
|
@@ -1468,16 +1517,20 @@ const ChannelWithContext = <
|
|
|
1468
1517
|
}, [setThread, setThreadMessages]);
|
|
1469
1518
|
|
|
1470
1519
|
// hard limit to prevent you from scrolling faster than 1 page per 2 seconds
|
|
1471
|
-
const loadMoreThreadFinished =
|
|
1472
|
-
(
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1520
|
+
const loadMoreThreadFinished = useRef(
|
|
1521
|
+
debounce(
|
|
1522
|
+
(
|
|
1523
|
+
newThreadHasMore: boolean,
|
|
1524
|
+
updatedThreadMessages: ChannelState<At, Ch, Co, Ev, Me, Re, Us>['threads'][string],
|
|
1525
|
+
) => {
|
|
1526
|
+
setThreadHasMore(newThreadHasMore);
|
|
1527
|
+
setThreadLoadingMore(false);
|
|
1528
|
+
setThreadMessages(updatedThreadMessages);
|
|
1529
|
+
},
|
|
1530
|
+
defaultDebounceInterval,
|
|
1531
|
+
debounceOptions,
|
|
1532
|
+
),
|
|
1533
|
+
).current;
|
|
1481
1534
|
|
|
1482
1535
|
const loadMoreThread: ThreadContextValue<At, Ch, Co, Ev, Me, Re, Us>['loadMoreThread'] =
|
|
1483
1536
|
async () => {
|
|
@@ -1522,12 +1575,14 @@ const ChannelWithContext = <
|
|
|
1522
1575
|
channel,
|
|
1523
1576
|
disabled: !!channel?.data?.frozen && disableIfFrozenChannel,
|
|
1524
1577
|
EmptyStateIndicator,
|
|
1578
|
+
enableMessageGroupingByUser,
|
|
1525
1579
|
enforceUniqueReaction,
|
|
1526
1580
|
error,
|
|
1527
1581
|
giphyEnabled:
|
|
1528
1582
|
giphyEnabled ??
|
|
1529
1583
|
!!(channel?.getConfig?.()?.commands || [])?.some((command) => command.name === 'giphy'),
|
|
1530
1584
|
hideDateSeparators,
|
|
1585
|
+
hideStickyDateHeader,
|
|
1531
1586
|
isAdmin,
|
|
1532
1587
|
isModerator,
|
|
1533
1588
|
isOwner,
|
|
@@ -1620,6 +1675,7 @@ const ChannelWithContext = <
|
|
|
1620
1675
|
disableTypingIndicator,
|
|
1621
1676
|
dismissKeyboardOnMessageTouch,
|
|
1622
1677
|
editMessage: editMessageProp,
|
|
1678
|
+
enableMessageGroupingByUser,
|
|
1623
1679
|
FileAttachment,
|
|
1624
1680
|
FileAttachmentGroup,
|
|
1625
1681
|
FileAttachmentIcon,
|
|
@@ -1642,6 +1698,7 @@ const ChannelWithContext = <
|
|
|
1642
1698
|
initialScrollToFirstUnreadMessage,
|
|
1643
1699
|
InlineDateSeparator,
|
|
1644
1700
|
InlineUnreadIndicator,
|
|
1701
|
+
legacyImageViewerSwipeBehaviour,
|
|
1645
1702
|
markdownRules,
|
|
1646
1703
|
Message,
|
|
1647
1704
|
messageActions,
|
|
@@ -24,10 +24,12 @@ export const useCreateChannelContext = <
|
|
|
24
24
|
channel,
|
|
25
25
|
disabled,
|
|
26
26
|
EmptyStateIndicator,
|
|
27
|
+
enableMessageGroupingByUser,
|
|
27
28
|
enforceUniqueReaction,
|
|
28
29
|
error,
|
|
29
30
|
giphyEnabled,
|
|
30
31
|
hideDateSeparators,
|
|
32
|
+
hideStickyDateHeader,
|
|
31
33
|
isAdmin,
|
|
32
34
|
isModerator,
|
|
33
35
|
isOwner,
|
|
@@ -64,10 +66,12 @@ export const useCreateChannelContext = <
|
|
|
64
66
|
channel,
|
|
65
67
|
disabled,
|
|
66
68
|
EmptyStateIndicator,
|
|
69
|
+
enableMessageGroupingByUser,
|
|
67
70
|
enforceUniqueReaction,
|
|
68
71
|
error,
|
|
69
72
|
giphyEnabled,
|
|
70
73
|
hideDateSeparators,
|
|
74
|
+
hideStickyDateHeader,
|
|
71
75
|
isAdmin,
|
|
72
76
|
isModerator,
|
|
73
77
|
isOwner,
|
|
@@ -37,6 +37,7 @@ export const useCreateMessagesContext = <
|
|
|
37
37
|
disableTypingIndicator,
|
|
38
38
|
dismissKeyboardOnMessageTouch,
|
|
39
39
|
editMessage,
|
|
40
|
+
enableMessageGroupingByUser,
|
|
40
41
|
FileAttachment,
|
|
41
42
|
FileAttachmentGroup,
|
|
42
43
|
FileAttachmentIcon,
|
|
@@ -59,6 +60,7 @@ export const useCreateMessagesContext = <
|
|
|
59
60
|
initialScrollToFirstUnreadMessage,
|
|
60
61
|
InlineDateSeparator,
|
|
61
62
|
InlineUnreadIndicator,
|
|
63
|
+
legacyImageViewerSwipeBehaviour,
|
|
62
64
|
markdownRules,
|
|
63
65
|
Message,
|
|
64
66
|
messageActions,
|
|
@@ -130,6 +132,7 @@ export const useCreateMessagesContext = <
|
|
|
130
132
|
disableTypingIndicator,
|
|
131
133
|
dismissKeyboardOnMessageTouch,
|
|
132
134
|
editMessage,
|
|
135
|
+
enableMessageGroupingByUser,
|
|
133
136
|
FileAttachment,
|
|
134
137
|
FileAttachmentGroup,
|
|
135
138
|
FileAttachmentIcon,
|
|
@@ -152,6 +155,7 @@ export const useCreateMessagesContext = <
|
|
|
152
155
|
initialScrollToFirstUnreadMessage,
|
|
153
156
|
InlineDateSeparator,
|
|
154
157
|
InlineUnreadIndicator,
|
|
158
|
+
legacyImageViewerSwipeBehaviour,
|
|
155
159
|
markdownRules,
|
|
156
160
|
Message,
|
|
157
161
|
messageActions,
|
|
@@ -43,7 +43,7 @@ export type MessageSimplePropsWithContext<
|
|
|
43
43
|
> &
|
|
44
44
|
Pick<
|
|
45
45
|
MessagesContextValue<At, Ch, Co, Ev, Me, Re, Us>,
|
|
46
|
-
'MessageAvatar' | 'MessageContent' | 'ReactionList'
|
|
46
|
+
'enableMessageGroupingByUser' | 'MessageAvatar' | 'MessageContent' | 'ReactionList'
|
|
47
47
|
>;
|
|
48
48
|
|
|
49
49
|
const MessageSimpleWithContext = <
|
|
@@ -60,6 +60,7 @@ const MessageSimpleWithContext = <
|
|
|
60
60
|
const {
|
|
61
61
|
alignment,
|
|
62
62
|
channel,
|
|
63
|
+
enableMessageGroupingByUser,
|
|
63
64
|
groupStyles,
|
|
64
65
|
hasReactions,
|
|
65
66
|
message,
|
|
@@ -89,7 +90,11 @@ const MessageSimpleWithContext = <
|
|
|
89
90
|
styles.container,
|
|
90
91
|
{
|
|
91
92
|
justifyContent: alignment === 'left' ? 'flex-start' : 'flex-end',
|
|
92
|
-
marginBottom: hasMarginBottom
|
|
93
|
+
marginBottom: hasMarginBottom
|
|
94
|
+
? isVeryLastMessage && enableMessageGroupingByUser
|
|
95
|
+
? 30
|
|
96
|
+
: 8
|
|
97
|
+
: 0,
|
|
93
98
|
marginTop: showReactions ? 2 : 0,
|
|
94
99
|
},
|
|
95
100
|
container,
|
|
@@ -211,7 +216,7 @@ export const MessageSimple = <
|
|
|
211
216
|
) => {
|
|
212
217
|
const { alignment, channel, groupStyles, hasReactions, message } =
|
|
213
218
|
useMessageContext<At, Ch, Co, Ev, Me, Re, Us>();
|
|
214
|
-
const { MessageAvatar, MessageContent, ReactionList } =
|
|
219
|
+
const { enableMessageGroupingByUser, MessageAvatar, MessageContent, ReactionList } =
|
|
215
220
|
useMessagesContext<At, Ch, Co, Ev, Me, Re, Us>();
|
|
216
221
|
|
|
217
222
|
return (
|
|
@@ -219,6 +224,7 @@ export const MessageSimple = <
|
|
|
219
224
|
{...{
|
|
220
225
|
alignment,
|
|
221
226
|
channel,
|
|
227
|
+
enableMessageGroupingByUser,
|
|
222
228
|
groupStyles,
|
|
223
229
|
hasReactions,
|
|
224
230
|
message,
|
|
@@ -34,6 +34,10 @@ const styles = StyleSheet.create({
|
|
|
34
34
|
dismiss: {
|
|
35
35
|
borderRadius: 24,
|
|
36
36
|
height: 24,
|
|
37
|
+
position: 'absolute',
|
|
38
|
+
right: 14,
|
|
39
|
+
top: 4,
|
|
40
|
+
width: 24,
|
|
37
41
|
},
|
|
38
42
|
fileContainer: {
|
|
39
43
|
borderRadius: 12,
|
|
@@ -112,62 +116,68 @@ const FileUploadPreviewWithContext = <
|
|
|
112
116
|
},
|
|
113
117
|
},
|
|
114
118
|
} = useTheme();
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
119
|
+
|
|
120
|
+
const renderItem = ({ index, item }: { index: number; item: FileUpload }) => {
|
|
121
|
+
const indicatorType =
|
|
122
|
+
item.state === FileState.UPLOADING
|
|
123
|
+
? ProgressIndicatorTypes.IN_PROGRESS
|
|
124
|
+
: item.state === FileState.UPLOAD_FAILED
|
|
125
|
+
? ProgressIndicatorTypes.RETRY
|
|
126
|
+
: undefined;
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<>
|
|
130
|
+
<UploadProgressIndicator
|
|
131
|
+
action={() => {
|
|
132
|
+
uploadFile({ newFile: item });
|
|
133
|
+
}}
|
|
134
|
+
active={item.state !== FileState.UPLOADED && item.state !== FileState.FINISHED}
|
|
135
|
+
style={styles.overlay}
|
|
136
|
+
type={indicatorType}
|
|
137
|
+
>
|
|
138
|
+
<View
|
|
139
|
+
style={[
|
|
140
|
+
styles.fileContainer,
|
|
141
|
+
index === fileUploads.length - 1
|
|
142
|
+
? {
|
|
143
|
+
marginBottom: 0,
|
|
144
|
+
}
|
|
145
|
+
: {},
|
|
146
|
+
{
|
|
147
|
+
borderColor: grey_whisper,
|
|
148
|
+
width: flatListWidth - 16,
|
|
149
|
+
},
|
|
150
|
+
fileContainer,
|
|
151
|
+
]}
|
|
152
|
+
>
|
|
153
|
+
<View style={[styles.fileContentContainer, fileContentContainer]}>
|
|
154
|
+
<FileAttachmentIcon mimeType={item.file.type} />
|
|
155
|
+
<View style={[styles.fileTextContainer, fileTextContainer]}>
|
|
156
|
+
<Text
|
|
157
|
+
numberOfLines={1}
|
|
158
|
+
style={[
|
|
159
|
+
styles.filenameText,
|
|
160
|
+
{
|
|
161
|
+
color: black,
|
|
162
|
+
width:
|
|
163
|
+
flatListWidth -
|
|
164
|
+
16 - // 16 = horizontal padding
|
|
165
|
+
40 - // 40 = file icon size
|
|
166
|
+
24 - // 24 = close icon size
|
|
167
|
+
24, // 24 = internal padding
|
|
168
|
+
},
|
|
169
|
+
filenameText,
|
|
170
|
+
]}
|
|
171
|
+
>
|
|
172
|
+
{item.file.name || ''}
|
|
173
|
+
</Text>
|
|
174
|
+
<Text style={[styles.fileSizeText, { color: grey }, fileSizeText]}>
|
|
175
|
+
{getFileSizeDisplayText(item.file.size)}
|
|
176
|
+
</Text>
|
|
177
|
+
</View>
|
|
178
|
+
</View>
|
|
169
179
|
</View>
|
|
170
|
-
</
|
|
180
|
+
</UploadProgressIndicator>
|
|
171
181
|
<TouchableOpacity
|
|
172
182
|
onPress={() => {
|
|
173
183
|
removeFile(item.id);
|
|
@@ -177,9 +187,9 @@ const FileUploadPreviewWithContext = <
|
|
|
177
187
|
>
|
|
178
188
|
<Close />
|
|
179
189
|
</TouchableOpacity>
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
190
|
+
</>
|
|
191
|
+
);
|
|
192
|
+
};
|
|
183
193
|
|
|
184
194
|
const fileUploadsLength = fileUploads.length;
|
|
185
195
|
|