stream-chat-react-native-core 3.9.0-next.1 → 3.9.0-next.5
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 +22 -12
- 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/ChannelList/hooks/usePaginatedChannels.js +14 -20
- package/lib/commonjs/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/commonjs/components/Chat/hooks/useIsOnline.js +7 -4
- package/lib/commonjs/components/Chat/hooks/useIsOnline.js.map +1 -1
- package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleView.js +20 -12
- package/lib/commonjs/components/KeyboardCompatibleView/KeyboardCompatibleView.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/MessageList/MessageList.js +43 -32
- 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/hooks/useAppStateListener.js +8 -5
- package/lib/commonjs/hooks/useAppStateListener.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 +22 -12
- 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/ChannelList/hooks/usePaginatedChannels.js +14 -20
- package/lib/module/components/ChannelList/hooks/usePaginatedChannels.js.map +1 -1
- package/lib/module/components/Chat/hooks/useIsOnline.js +7 -4
- package/lib/module/components/Chat/hooks/useIsOnline.js.map +1 -1
- package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleView.js +20 -12
- package/lib/module/components/KeyboardCompatibleView/KeyboardCompatibleView.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/MessageList/MessageList.js +43 -32
- 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/hooks/useAppStateListener.js +8 -5
- package/lib/module/hooks/useAppStateListener.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 +2 -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/KeyboardCompatibleView/KeyboardCompatibleView.d.ts +2 -1
- 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 +2 -2
- package/src/components/Attachment/Gallery.tsx +20 -5
- package/src/components/Channel/Channel.tsx +10 -0
- package/src/components/Channel/hooks/useCreateChannelContext.ts +4 -0
- package/src/components/Channel/hooks/useCreateMessagesContext.ts +4 -0
- package/src/components/ChannelList/hooks/usePaginatedChannels.ts +1 -3
- package/src/components/Chat/hooks/useIsOnline.ts +17 -16
- package/src/components/KeyboardCompatibleView/KeyboardCompatibleView.tsx +9 -2
- package/src/components/Message/MessageSimple/MessageSimple.tsx +9 -3
- package/src/components/MessageList/MessageList.tsx +72 -28
- 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/hooks/useAppStateListener.ts +26 -12
- package/src/version.json +1 -1
|
@@ -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,
|
|
@@ -57,7 +57,6 @@ export const usePaginatedChannels = <
|
|
|
57
57
|
const lastRefresh = useRef(Date.now());
|
|
58
58
|
const [loadingChannels, setLoadingChannels] = useState(false);
|
|
59
59
|
const [loadingNextPage, setLoadingNextPage] = useState(false);
|
|
60
|
-
const [offset, setOffset] = useState(0);
|
|
61
60
|
const [refreshing, setRefreshing] = useState(false);
|
|
62
61
|
|
|
63
62
|
const queryChannels = async (queryType = '', retryCount = 0): Promise<void> => {
|
|
@@ -73,7 +72,7 @@ export const usePaginatedChannels = <
|
|
|
73
72
|
|
|
74
73
|
const newOptions = {
|
|
75
74
|
limit: options?.limit ?? MAX_QUERY_CHANNELS_LIMIT,
|
|
76
|
-
offset: queryType === 'reload' || queryType === 'refresh' ? 0 :
|
|
75
|
+
offset: queryType === 'reload' || queryType === 'refresh' ? 0 : channels.length,
|
|
77
76
|
...options,
|
|
78
77
|
};
|
|
79
78
|
|
|
@@ -89,7 +88,6 @@ export const usePaginatedChannels = <
|
|
|
89
88
|
|
|
90
89
|
setChannels(newChannels);
|
|
91
90
|
setHasNextPage(channelQueryResponse.length >= newOptions.limit);
|
|
92
|
-
setOffset(newChannels.length);
|
|
93
91
|
setError(false);
|
|
94
92
|
} catch (err) {
|
|
95
93
|
await wait(2000);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useAppStateListener } from '../../../hooks/useAppStateListener';
|
|
4
4
|
import { NetInfo } from '../../../native';
|
|
@@ -41,22 +41,23 @@ export const useIsOnline = <
|
|
|
41
41
|
|
|
42
42
|
const clientExits = !!client;
|
|
43
43
|
|
|
44
|
-
const onBackground =
|
|
45
|
-
|
|
46
|
-
for (const cid in client.activeChannels) {
|
|
47
|
-
const channel = client.activeChannels[cid];
|
|
48
|
-
channel?.state.setIsUpToDate(false);
|
|
49
|
-
}
|
|
50
|
-
client.closeConnection();
|
|
51
|
-
setIsOnline(false);
|
|
52
|
-
}
|
|
53
|
-
: undefined;
|
|
44
|
+
const onBackground = useCallback(() => {
|
|
45
|
+
if (!closeConnectionOnBackground) return;
|
|
54
46
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
47
|
+
for (const cid in client.activeChannels) {
|
|
48
|
+
const channel = client.activeChannels[cid];
|
|
49
|
+
channel?.state.setIsUpToDate(false);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
client.closeConnection();
|
|
53
|
+
setIsOnline(false);
|
|
54
|
+
}, [closeConnectionOnBackground, client]);
|
|
55
|
+
|
|
56
|
+
const onForeground = useCallback(() => {
|
|
57
|
+
if (!closeConnectionOnBackground) return;
|
|
58
|
+
|
|
59
|
+
client.openConnection();
|
|
60
|
+
}, [closeConnectionOnBackground, client]);
|
|
60
61
|
|
|
61
62
|
useAppStateListener(onForeground, onBackground);
|
|
62
63
|
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
LayoutAnimation,
|
|
12
12
|
LayoutChangeEvent,
|
|
13
13
|
LayoutRectangle,
|
|
14
|
+
NativeEventSubscription,
|
|
14
15
|
Platform,
|
|
15
16
|
ScreenRect,
|
|
16
17
|
StatusBar,
|
|
@@ -42,6 +43,7 @@ export class KeyboardCompatibleView extends React.Component<
|
|
|
42
43
|
_frame: LayoutRectangle | null = null;
|
|
43
44
|
_keyboardEvent: KeyboardEvent | null = null;
|
|
44
45
|
_subscriptions: EmitterSubscription[] = [];
|
|
46
|
+
_appStateSubscription: NativeEventSubscription | null = null;
|
|
45
47
|
viewRef: React.RefObject<View>;
|
|
46
48
|
_initialFrameHeight = 0;
|
|
47
49
|
constructor(props: KeyboardAvoidingViewProps) {
|
|
@@ -178,12 +180,17 @@ export class KeyboardCompatibleView extends React.Component<
|
|
|
178
180
|
};
|
|
179
181
|
|
|
180
182
|
componentDidMount() {
|
|
181
|
-
AppState.addEventListener('change', this._handleAppStateChange);
|
|
183
|
+
this._appStateSubscription = AppState.addEventListener('change', this._handleAppStateChange);
|
|
182
184
|
this.setKeyboardListeners();
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
componentWillUnmount() {
|
|
186
|
-
|
|
188
|
+
// Following if-else condition to avoid deprecated warning coming RN 0.65
|
|
189
|
+
if (this._appStateSubscription?.remove) {
|
|
190
|
+
this._appStateSubscription?.remove();
|
|
191
|
+
} else {
|
|
192
|
+
AppState.removeEventListener('change', this._handleAppStateChange);
|
|
193
|
+
}
|
|
187
194
|
this.unsetKeyboardListeners();
|
|
188
195
|
}
|
|
189
196
|
|
|
@@ -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,
|
|
@@ -131,6 +131,7 @@ type MessageListPropsWithContext<
|
|
|
131
131
|
| 'channel'
|
|
132
132
|
| 'disabled'
|
|
133
133
|
| 'EmptyStateIndicator'
|
|
134
|
+
| 'hideStickyDateHeader'
|
|
134
135
|
| 'loadChannelAtMessage'
|
|
135
136
|
| 'loading'
|
|
136
137
|
| 'LoadingIndicator'
|
|
@@ -158,6 +159,7 @@ type MessageListPropsWithContext<
|
|
|
158
159
|
| 'initialScrollToFirstUnreadMessage'
|
|
159
160
|
| 'InlineDateSeparator'
|
|
160
161
|
| 'InlineUnreadIndicator'
|
|
162
|
+
| 'legacyImageViewerSwipeBehaviour'
|
|
161
163
|
| 'Message'
|
|
162
164
|
| 'ScrollToBottomButton'
|
|
163
165
|
| 'MessageSystem'
|
|
@@ -264,10 +266,12 @@ const MessageListWithContext = <
|
|
|
264
266
|
FlatList,
|
|
265
267
|
FooterComponent = LoadingMoreIndicator,
|
|
266
268
|
HeaderComponent = InlineLoadingMoreRecentIndicator,
|
|
269
|
+
hideStickyDateHeader,
|
|
267
270
|
initialScrollToFirstUnreadMessage,
|
|
268
271
|
InlineDateSeparator,
|
|
269
272
|
InlineUnreadIndicator,
|
|
270
273
|
inverted = true,
|
|
274
|
+
legacyImageViewerSwipeBehaviour,
|
|
271
275
|
loadChannelAtMessage,
|
|
272
276
|
loading,
|
|
273
277
|
LoadingIndicator,
|
|
@@ -410,7 +414,7 @@ const MessageListWithContext = <
|
|
|
410
414
|
*/
|
|
411
415
|
const onViewableItemsChanged = useRef(
|
|
412
416
|
({ viewableItems }: { viewableItems: ViewToken[] | undefined }) => {
|
|
413
|
-
if (viewableItems) {
|
|
417
|
+
if (viewableItems && !hideStickyDateHeader) {
|
|
414
418
|
updateStickyHeaderDateIfNeeded(viewableItems);
|
|
415
419
|
}
|
|
416
420
|
setInitialScrollIfNeeded();
|
|
@@ -427,7 +431,26 @@ const MessageListWithContext = <
|
|
|
427
431
|
}, [disabled]);
|
|
428
432
|
|
|
429
433
|
useEffect(() => {
|
|
430
|
-
|
|
434
|
+
/**
|
|
435
|
+
* 1. !initialScrollToFirstUnreadMessage && channel.countUnread() > 0
|
|
436
|
+
*
|
|
437
|
+
* In this case MessageList won't scroll to first unread message when opened, so we can mark
|
|
438
|
+
* the channel as read right after opening.
|
|
439
|
+
*
|
|
440
|
+
* 2. initialScrollToFirstUnreadMessage && channel.countUnread() <= scrollToFirstUnreadThreshold
|
|
441
|
+
*
|
|
442
|
+
* In this case MessageList will be opened to first unread message.
|
|
443
|
+
* But if there are not enough (scrollToFirstUnreadThreshold) unread messages, then MessageList
|
|
444
|
+
* won't need to scroll up. So we can safely mark the channel as read right after opening.
|
|
445
|
+
*/
|
|
446
|
+
const shouldMarkReadOnFirstLoad =
|
|
447
|
+
!loading &&
|
|
448
|
+
channel &&
|
|
449
|
+
((!initialScrollToFirstUnreadMessage && channel.countUnread() > 0) ||
|
|
450
|
+
(initialScrollToFirstUnreadMessage &&
|
|
451
|
+
channel.countUnread() <= scrollToFirstUnreadThreshold));
|
|
452
|
+
|
|
453
|
+
if (shouldMarkReadOnFirstLoad) {
|
|
431
454
|
markRead();
|
|
432
455
|
}
|
|
433
456
|
}, [loading]);
|
|
@@ -785,44 +808,58 @@ const MessageListWithContext = <
|
|
|
785
808
|
[messageListLengthAfterUpdate],
|
|
786
809
|
);
|
|
787
810
|
|
|
788
|
-
const messagesWithImages =
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
811
|
+
const messagesWithImages =
|
|
812
|
+
legacyImageViewerSwipeBehaviour &&
|
|
813
|
+
messageList.filter((message) => {
|
|
814
|
+
if (!message.deleted_at && message.attachments) {
|
|
815
|
+
return message.attachments.some(
|
|
816
|
+
(attachment) =>
|
|
817
|
+
attachment.type === 'image' &&
|
|
818
|
+
!attachment.title_link &&
|
|
819
|
+
!attachment.og_scrape_url &&
|
|
820
|
+
(attachment.image_url || attachment.thumb_url),
|
|
821
|
+
);
|
|
822
|
+
}
|
|
823
|
+
return false;
|
|
824
|
+
});
|
|
800
825
|
|
|
801
826
|
/**
|
|
802
827
|
* This is for the useEffect to run again in the case that a message
|
|
803
828
|
* gets edited with more or the same number of images
|
|
804
829
|
*/
|
|
805
|
-
const imageString =
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
830
|
+
const imageString =
|
|
831
|
+
legacyImageViewerSwipeBehaviour &&
|
|
832
|
+
messagesWithImages &&
|
|
833
|
+
messagesWithImages
|
|
834
|
+
.map((message) =>
|
|
835
|
+
message.attachments
|
|
836
|
+
?.map((attachment) => attachment.image_url || attachment.thumb_url || '')
|
|
837
|
+
.join(),
|
|
838
|
+
)
|
|
839
|
+
.join();
|
|
840
|
+
|
|
841
|
+
const numberOfMessagesWithImages =
|
|
842
|
+
legacyImageViewerSwipeBehaviour && messagesWithImages && messagesWithImages.length;
|
|
814
843
|
const threadExists = !!thread;
|
|
844
|
+
|
|
815
845
|
useEffect(() => {
|
|
816
|
-
if ((threadList && thread) || (!threadList && !thread)) {
|
|
817
|
-
setImages(messagesWithImages);
|
|
846
|
+
if (legacyImageViewerSwipeBehaviour && ((threadList && thread) || (!threadList && !thread))) {
|
|
847
|
+
setImages(messagesWithImages as MessageType<At, Ch, Co, Ev, Me, Re, Us>[]);
|
|
818
848
|
}
|
|
819
|
-
}, [
|
|
849
|
+
}, [
|
|
850
|
+
imageString,
|
|
851
|
+
legacyImageViewerSwipeBehaviour,
|
|
852
|
+
numberOfMessagesWithImages,
|
|
853
|
+
threadExists,
|
|
854
|
+
threadList,
|
|
855
|
+
]);
|
|
820
856
|
|
|
821
857
|
const stickyHeaderFormatDate =
|
|
822
858
|
stickyHeaderDate?.getFullYear() === new Date().getFullYear() ? 'MMM D' : 'MMM D, YYYY';
|
|
823
|
-
const tStickyHeaderDate =
|
|
859
|
+
const tStickyHeaderDate =
|
|
860
|
+
stickyHeaderDate && !hideStickyDateHeader ? tDateTimeParser(stickyHeaderDate) : null;
|
|
824
861
|
const stickyHeaderDateToRender =
|
|
825
|
-
tStickyHeaderDate === null
|
|
862
|
+
tStickyHeaderDate === null || hideStickyDateHeader
|
|
826
863
|
? null
|
|
827
864
|
: isDayOrMoment(tStickyHeaderDate)
|
|
828
865
|
? tStickyHeaderDate.format(stickyHeaderFormatDate)
|
|
@@ -943,7 +980,9 @@ export const MessageList = <
|
|
|
943
980
|
channel,
|
|
944
981
|
disabled,
|
|
945
982
|
EmptyStateIndicator,
|
|
983
|
+
enableMessageGroupingByUser,
|
|
946
984
|
error,
|
|
985
|
+
hideStickyDateHeader,
|
|
947
986
|
loadChannelAtMessage,
|
|
948
987
|
loading,
|
|
949
988
|
LoadingIndicator,
|
|
@@ -965,6 +1004,7 @@ export const MessageList = <
|
|
|
965
1004
|
initialScrollToFirstUnreadMessage,
|
|
966
1005
|
InlineDateSeparator,
|
|
967
1006
|
InlineUnreadIndicator,
|
|
1007
|
+
legacyImageViewerSwipeBehaviour,
|
|
968
1008
|
Message,
|
|
969
1009
|
MessageSystem,
|
|
970
1010
|
myMessageTheme,
|
|
@@ -987,11 +1027,14 @@ export const MessageList = <
|
|
|
987
1027
|
disabled,
|
|
988
1028
|
disableTypingIndicator,
|
|
989
1029
|
EmptyStateIndicator,
|
|
1030
|
+
enableMessageGroupingByUser,
|
|
990
1031
|
error,
|
|
991
1032
|
FlatList,
|
|
1033
|
+
hideStickyDateHeader,
|
|
992
1034
|
initialScrollToFirstUnreadMessage,
|
|
993
1035
|
InlineDateSeparator,
|
|
994
1036
|
InlineUnreadIndicator,
|
|
1037
|
+
legacyImageViewerSwipeBehaviour,
|
|
995
1038
|
loadChannelAtMessage,
|
|
996
1039
|
loading,
|
|
997
1040
|
LoadingIndicator,
|
|
@@ -1021,6 +1064,7 @@ export const MessageList = <
|
|
|
1021
1064
|
TypingIndicatorContainer,
|
|
1022
1065
|
}}
|
|
1023
1066
|
{...props}
|
|
1067
|
+
noGroupByUser={!enableMessageGroupingByUser || props.noGroupByUser}
|
|
1024
1068
|
/>
|
|
1025
1069
|
);
|
|
1026
1070
|
};
|
|
@@ -116,7 +116,7 @@ export const useMessageList = <
|
|
|
116
116
|
.map((msg) => ({
|
|
117
117
|
...msg,
|
|
118
118
|
dateSeparator: dateSeparators[msg.id] || undefined,
|
|
119
|
-
groupStyles: messageGroupStyles[msg.id] || [],
|
|
119
|
+
groupStyles: messageGroupStyles[msg.id] || ['single'],
|
|
120
120
|
readBy: msg.id ? readData[msg.id] || false : false,
|
|
121
121
|
}));
|
|
122
122
|
|
|
@@ -53,6 +53,9 @@ export const getGroupStyles = <
|
|
|
53
53
|
noGroupByUser,
|
|
54
54
|
userId,
|
|
55
55
|
} = params;
|
|
56
|
+
|
|
57
|
+
if (noGroupByUser) return {};
|
|
58
|
+
|
|
56
59
|
const messageGroupStyles: { [key: string]: GroupType[] } = {};
|
|
57
60
|
|
|
58
61
|
const messagesFilteredForNonUser = messages.filter(
|
|
@@ -128,14 +131,6 @@ export const getGroupStyles = <
|
|
|
128
131
|
}
|
|
129
132
|
}
|
|
130
133
|
|
|
131
|
-
/**
|
|
132
|
-
* If noGroupByUser set add the key for single
|
|
133
|
-
*/
|
|
134
|
-
if (noGroupByUser) {
|
|
135
|
-
groupStyles.splice(0, groupStyles.length);
|
|
136
|
-
groupStyles.push('single');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
134
|
if (message.id) {
|
|
140
135
|
messageGroupStyles[message.id] = groupStyles;
|
|
141
136
|
}
|
|
@@ -53,6 +53,7 @@ export type ChannelContextValue<
|
|
|
53
53
|
* Hide inline date separators on channel
|
|
54
54
|
*/
|
|
55
55
|
hideDateSeparators: boolean;
|
|
56
|
+
hideStickyDateHeader: boolean;
|
|
56
57
|
/**
|
|
57
58
|
* Returns true if the current user has admin privileges
|
|
58
59
|
*/
|
|
@@ -164,6 +165,7 @@ export type ChannelContextValue<
|
|
|
164
165
|
*/
|
|
165
166
|
channel?: Channel<At, Ch, Co, Ev, Me, Re, Us>;
|
|
166
167
|
disabled?: boolean;
|
|
168
|
+
enableMessageGroupingByUser?: boolean;
|
|
167
169
|
lastRead?: Date;
|
|
168
170
|
/**
|
|
169
171
|
* Maximum time in milliseconds that should occur between messages
|
|
@@ -97,6 +97,7 @@ export type MessagesContextValue<
|
|
|
97
97
|
DateHeader: React.ComponentType<DateHeaderProps>;
|
|
98
98
|
/** Should keyboard be dismissed when messaged is touched */
|
|
99
99
|
dismissKeyboardOnMessageTouch: boolean;
|
|
100
|
+
enableMessageGroupingByUser: boolean;
|
|
100
101
|
/**
|
|
101
102
|
* UI component to display File type attachment.
|
|
102
103
|
* Defaults to: [FileAttachment](https://github.com/GetStream/stream-chat-react-native/blob/master/src/components/Attachment/FileAttachment.tsx)
|
|
@@ -326,6 +327,7 @@ export type MessagesContextValue<
|
|
|
326
327
|
handleRetry?: (message: MessageType<At, Ch, Co, Ev, Me, Re, Us>) => Promise<void>;
|
|
327
328
|
/** Handler to access when a thread reply action is invoked */
|
|
328
329
|
handleThreadReply?: (message: MessageType<At, Ch, Co, Ev, Me, Re, Us>) => Promise<void>;
|
|
330
|
+
legacyImageViewerSwipeBehaviour?: boolean;
|
|
329
331
|
/** Object specifying rules defined within simple-markdown https://github.com/Khan/simple-markdown#adding-a-simple-extension */
|
|
330
332
|
markdownRules?: MarkdownRules;
|
|
331
333
|
/**
|
|
@@ -1,21 +1,35 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
import { AppState, AppStateStatus } from 'react-native';
|
|
3
3
|
|
|
4
4
|
export const useAppStateListener = (onForeground?: () => void, onBackground?: () => void) => {
|
|
5
5
|
const [appState, setAppState] = useState(AppState.currentState);
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
const handleAppStateChange = useCallback(
|
|
7
|
+
(nextAppState: AppStateStatus) => {
|
|
8
|
+
if (appState === 'background' && nextAppState === 'active' && onForeground) {
|
|
9
|
+
onForeground();
|
|
10
|
+
} else if (
|
|
11
|
+
appState.match(/active|inactive/) &&
|
|
12
|
+
nextAppState === 'background' &&
|
|
13
|
+
onBackground
|
|
14
|
+
) {
|
|
15
|
+
onBackground();
|
|
16
|
+
}
|
|
17
|
+
setAppState(nextAppState);
|
|
18
|
+
},
|
|
19
|
+
[onBackground, onForeground, appState],
|
|
20
|
+
);
|
|
15
21
|
|
|
16
22
|
useEffect(() => {
|
|
17
|
-
AppState.addEventListener('change', handleAppStateChange);
|
|
23
|
+
const subscription = AppState.addEventListener('change', handleAppStateChange);
|
|
18
24
|
|
|
19
|
-
return () =>
|
|
25
|
+
return () => {
|
|
26
|
+
// Following if-else logic is to support RN >= 0.65 and RN < 0.65 versions.
|
|
27
|
+
// https://github.com/react-native-community/releases/blob/master/CHANGELOG.md#:~:text=EventEmitter%23removeSubscription%20is%20now%20deprecated.%20(cb6cbd12f8%20by%20%40yungsters)
|
|
28
|
+
if (subscription?.remove) {
|
|
29
|
+
subscription.remove();
|
|
30
|
+
} else {
|
|
31
|
+
AppState.removeEventListener('change', handleAppStateChange);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
20
34
|
}, [handleAppStateChange]);
|
|
21
35
|
};
|
package/src/version.json
CHANGED