Skip to content

Commit c9064d6

Browse files
committed
feat: remove deprecated APIs and props from useMessageList and channel unread state
1 parent 5248e2b commit c9064d6

File tree

12 files changed

+3
-205
lines changed

12 files changed

+3
-205
lines changed

package/src/components/Channel/Channel.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ export type ChannelPropsWithContext = Pick<ChannelContextValue, 'channel'> &
324324
| 'FlatList'
325325
| 'forceAlignMessages'
326326
| 'Gallery'
327-
| 'getMessagesGroupStyles'
328327
| 'getMessageGroupStyle'
329328
| 'Giphy'
330329
| 'giphyVersion'
@@ -614,7 +613,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
614613
FlatList = NativeHandlers.FlatList,
615614
forceAlignMessages,
616615
Gallery = GalleryDefault,
617-
getMessagesGroupStyles,
618616
getMessageGroupStyle,
619617
Giphy = GiphyDefault,
620618
giphyVersion = 'fixed_height',
@@ -1765,7 +1763,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
17651763

17661764
const channelContext = useCreateChannelContext({
17671765
channel,
1768-
channelUnreadState: channelUnreadStateStore.channelUnreadState,
17691766
channelUnreadStateStore,
17701767
disabled: !!channel?.data?.frozen,
17711768
EmptyStateIndicator,
@@ -1915,7 +1912,6 @@ const ChannelWithContext = (props: PropsWithChildren<ChannelPropsWithContext>) =
19151912
forceAlignMessages,
19161913
Gallery,
19171914
getMessageGroupStyle,
1918-
getMessagesGroupStyles,
19191915
Giphy,
19201916
giphyVersion,
19211917
handleBan,

package/src/components/Channel/hooks/useCreateChannelContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import type { ChannelContextValue } from '../../../contexts/channelContext/Chann
44

55
export const useCreateChannelContext = ({
66
channel,
7-
channelUnreadState,
87
channelUnreadStateStore,
98
disabled,
109
EmptyStateIndicator,
@@ -51,7 +50,6 @@ export const useCreateChannelContext = ({
5150
const channelContext: ChannelContextValue = useMemo(
5251
() => ({
5352
channel,
54-
channelUnreadState,
5553
channelUnreadStateStore,
5654
disabled,
5755
EmptyStateIndicator,

package/src/components/Channel/hooks/useCreateMessagesContext.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const useCreateMessagesContext = ({
2828
forceAlignMessages,
2929
Gallery,
3030
getMessageGroupStyle,
31-
getMessagesGroupStyles,
3231
Giphy,
3332
giphyVersion,
3433
handleBan,
@@ -147,7 +146,6 @@ export const useCreateMessagesContext = ({
147146
forceAlignMessages,
148147
Gallery,
149148
getMessageGroupStyle,
150-
getMessagesGroupStyles,
151149
Giphy,
152150
giphyVersion,
153151
handleBan,

package/src/components/MessageList/MessageFlashList.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,6 @@ type MessageFlashListPropsWithContext = Pick<
105105
Pick<
106106
ChannelContextValue,
107107
| 'channel'
108-
| 'channelUnreadState'
109108
| 'channelUnreadStateStore'
110109
| 'disabled'
111110
| 'EmptyStateIndicator'
@@ -370,7 +369,6 @@ const MessageFlashListWithContext = (props: MessageFlashListPropsWithContext) =>
370369
} = useMessageList({
371370
isFlashList: true,
372371
isLiveStreaming,
373-
noGroupByUser,
374372
threadList,
375373
});
376374

@@ -1132,7 +1130,6 @@ export const MessageFlashList = (props: MessageFlashListProps) => {
11321130
const { closePicker, selectedPicker, setSelectedPicker } = useAttachmentPickerContext();
11331131
const {
11341132
channel,
1135-
channelUnreadState,
11361133
channelUnreadStateStore,
11371134
disabled,
11381135
EmptyStateIndicator,
@@ -1181,7 +1178,6 @@ export const MessageFlashList = (props: MessageFlashListProps) => {
11811178
<MessageFlashListWithContext
11821179
{...{
11831180
channel,
1184-
channelUnreadState,
11851181
channelUnreadStateStore,
11861182
client,
11871183
closePicker,

package/src/components/MessageList/MessageList.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ type MessageListPropsWithContext = Pick<
135135
Pick<
136136
ChannelContextValue,
137137
| 'channel'
138-
| 'channelUnreadState'
139138
| 'channelUnreadStateStore'
140139
| 'disabled'
141140
| 'EmptyStateIndicator'
@@ -339,7 +338,6 @@ const MessageListWithContext = (props: MessageListPropsWithContext) => {
339338
viewabilityChangedCallback,
340339
} = useMessageList({
341340
isLiveStreaming,
342-
noGroupByUser,
343341
threadList,
344342
});
345343
const messageListLengthBeforeUpdate = useRef(0);
@@ -1223,7 +1221,6 @@ export const MessageList = (props: MessageListProps) => {
12231221
const { closePicker, selectedPicker, setSelectedPicker } = useAttachmentPickerContext();
12241222
const {
12251223
channel,
1226-
channelUnreadState,
12271224
channelUnreadStateStore,
12281225
disabled,
12291226
EmptyStateIndicator,
@@ -1272,7 +1269,6 @@ export const MessageList = (props: MessageListProps) => {
12721269
<MessageListWithContext
12731270
{...{
12741271
channel,
1275-
channelUnreadState,
12761272
channelUnreadStateStore,
12771273
client,
12781274
closePicker,

package/src/components/MessageList/hooks/useMessageList.ts

Lines changed: 3 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { useEffect, useMemo, useRef } from 'react';
1+
import { useEffect, useMemo } from 'react';
22

33
import type { LocalMessage } from 'stream-chat';
44

5-
import { useChannelContext } from '../../../contexts/channelContext/ChannelContext';
65
import { useChatContext } from '../../../contexts/chatContext/ChatContext';
76
import {
87
DeletedMessagesVisibilityType,
@@ -13,15 +12,8 @@ import { useThreadContext } from '../../../contexts/threadContext/ThreadContext'
1312

1413
import { useRAFCoalescedValue } from '../../../hooks';
1514
import { MessagePreviousAndNextMessageStore } from '../../../state-store/message-list-prev-next-state';
16-
import { DateSeparators, getDateSeparators } from '../utils/getDateSeparators';
17-
import { getGroupStyles } from '../utils/getGroupStyles';
1815

1916
export type UseMessageListParams = {
20-
deletedMessagesVisibilityType?: DeletedMessagesVisibilityType;
21-
/**
22-
* @deprecated
23-
*/
24-
noGroupByUser?: boolean;
2517
threadList?: boolean;
2618
isLiveStreaming?: boolean;
2719
isFlashList?: boolean;
@@ -62,11 +54,9 @@ export const shouldIncludeMessageInList = (
6254
};
6355

6456
export const useMessageList = (params: UseMessageListParams) => {
65-
const { noGroupByUser, threadList, isLiveStreaming, isFlashList } = params;
57+
const { threadList, isLiveStreaming, isFlashList } = params;
6658
const { client } = useChatContext();
67-
const { hideDateSeparators, maxTimeBetweenGroupedMessages } = useChannelContext();
68-
const { deletedMessagesVisibilityType, getMessagesGroupStyles = getGroupStyles } =
69-
useMessagesContext();
59+
const { deletedMessagesVisibilityType } = useMessagesContext();
7060
const { messages, viewabilityChangedCallback } = usePaginatedMessageListContext();
7161
const { threadMessages } = useThreadContext();
7262
const messageList = threadList ? threadMessages : messages;
@@ -97,53 +87,6 @@ export const useMessageList = (params: UseMessageListParams) => {
9787
);
9888
}, [filteredMessageList, messageListPreviousAndNextMessageStore]);
9989

100-
/**
101-
* @deprecated use `useDateSeparator` hook instead directly in the Message.
102-
*/
103-
const dateSeparators = useMemo(
104-
() =>
105-
getDateSeparators({
106-
hideDateSeparators,
107-
messages: filteredMessageList,
108-
}),
109-
[hideDateSeparators, filteredMessageList],
110-
);
111-
112-
/**
113-
* @deprecated use `useDateSeparator` hook instead directly in the Message.
114-
*/
115-
const dateSeparatorsRef = useRef<DateSeparators>(dateSeparators);
116-
dateSeparatorsRef.current = dateSeparators;
117-
118-
/**
119-
* @deprecated use `useMessageGroupStyles` hook instead directly in the Message.
120-
*/
121-
const messageGroupStyles = useMemo(
122-
() =>
123-
getMessagesGroupStyles({
124-
dateSeparators: dateSeparatorsRef.current,
125-
hideDateSeparators,
126-
maxTimeBetweenGroupedMessages,
127-
messages: filteredMessageList,
128-
noGroupByUser,
129-
userId: client.userID,
130-
}),
131-
[
132-
getMessagesGroupStyles,
133-
hideDateSeparators,
134-
maxTimeBetweenGroupedMessages,
135-
filteredMessageList,
136-
noGroupByUser,
137-
client.userID,
138-
],
139-
);
140-
141-
/**
142-
* @deprecated use `useMessageGroupStyles` hook instead directly in the Message.
143-
*/
144-
const messageGroupStylesRef = useRef<MessageGroupStyles>(messageGroupStyles);
145-
messageGroupStylesRef.current = messageGroupStyles;
146-
14790
const processedMessageList = useMemo<LocalMessage[]>(() => {
14891
const newMessageList = [];
14992
for (const message of filteredMessageList) {
@@ -160,10 +103,6 @@ export const useMessageList = (params: UseMessageListParams) => {
160103

161104
return useMemo(
162105
() => ({
163-
/** Date separators */
164-
dateSeparatorsRef,
165-
/** Message group styles */
166-
messageGroupStylesRef,
167106
messageListPreviousAndNextMessageStore,
168107
/** Messages enriched with dates/readby/groups and also reversed in order */
169108
processedMessageList: data,

package/src/components/MessageList/utils/getDateSeparators.ts

Lines changed: 0 additions & 52 deletions
This file was deleted.

package/src/components/MessageList/utils/getGroupStyles.ts

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { LocalMessage } from 'stream-chat';
22

3-
import type { DateSeparators } from './getDateSeparators';
4-
5-
import type { PaginatedMessageListContextValue } from '../../../contexts/paginatedMessageListContext/PaginatedMessageListContext';
6-
import type { ThreadContextValue } from '../../../contexts/threadContext/ThreadContext';
7-
83
import { isEditedMessage } from '../../../utils/utils';
9-
import type { GroupType } from '../hooks/useMessageList';
104

115
export type MessageGroupStylesParams = {
126
message: LocalMessage;
@@ -17,24 +11,6 @@ export type MessageGroupStylesParams = {
1711
nextMessageDateSeparatorDate?: Date;
1812
};
1913

20-
/**
21-
* @deprecated in favor of `useMessageGroupStyles` hook instead directly in the Message.
22-
*/
23-
export type GetGroupStylesParams = {
24-
dateSeparators: DateSeparators;
25-
messages: PaginatedMessageListContextValue['messages'] | ThreadContextValue['threadMessages'];
26-
/**
27-
* @deprecated in favor of `useDateSeparator` hook instead directly in the Message.
28-
*/
29-
hideDateSeparators?: boolean;
30-
maxTimeBetweenGroupedMessages?: number;
31-
noGroupByUser?: boolean;
32-
/**
33-
* @deprecated
34-
*/
35-
userId?: string;
36-
};
37-
3814
export type GroupStyle = '' | 'middle' | 'top' | 'bottom' | 'single';
3915

4016
/**
@@ -118,34 +94,3 @@ export const getGroupStyle = ({
11894

11995
return groupStyles;
12096
};
121-
122-
/**
123-
* @deprecated in favor of `useMessageGroupStyles` hook instead directly in the Message.
124-
*/
125-
export const getGroupStyles = (params: GetGroupStylesParams) => {
126-
const { dateSeparators, maxTimeBetweenGroupedMessages, messages, noGroupByUser } = params;
127-
128-
if (noGroupByUser) {
129-
return {};
130-
}
131-
132-
const messageGroupStyles: { [key: string]: GroupType[] } = {};
133-
134-
for (let i = 0; i < messages.length; i++) {
135-
const previousMessage = messages[i - 1];
136-
const message = messages[i];
137-
const nextMessage = messages[i + 1];
138-
139-
if (message.id) {
140-
messageGroupStyles[message.id] = getGroupStyle({
141-
dateSeparatorDate: dateSeparators[message.id],
142-
maxTimeBetweenGroupedMessages,
143-
message,
144-
nextMessage,
145-
previousMessage,
146-
});
147-
}
148-
}
149-
150-
return messageGroupStyles;
151-
};

package/src/components/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ export * from './MessageList/NetworkDownIndicator';
157157
export * from './MessageList/ScrollToBottomButton';
158158
export * from './MessageList/TypingIndicator';
159159
export * from './MessageList/TypingIndicatorContainer';
160-
export * from './MessageList/utils/getDateSeparators';
161160
export * from './MessageList/utils/getGroupStyles';
162161
export * from './MessageList/utils/getLastReceivedMessage';
163162
export * from './Message/hooks/useMessageDeliveryData';

package/src/contexts/channelContext/ChannelContext.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import {
1010
ChannelUnreadStateStore,
1111
ChannelUnreadStateStoreType,
1212
} from '../../state-store/channel-unread-state';
13-
import { ChannelUnreadState } from '../../types/types';
1413
import { DEFAULT_BASE_CONTEXT_VALUE } from '../utils/defaultBaseContextValue';
1514

1615
import { isTestEnvironment } from '../utils/isTestEnvironment';
@@ -135,11 +134,6 @@ export type ChannelContextValue = {
135134
* Its a map of filename and AbortController
136135
*/
137136
uploadAbortControllerRef: React.MutableRefObject<Map<string, AbortController>>;
138-
/**
139-
* Channel unread data
140-
* @deprecated Use channelUnreadStateStore instead
141-
*/
142-
channelUnreadState?: ChannelUnreadState;
143137
channelUnreadStateStore: ChannelUnreadStateStore;
144138
disabled?: boolean;
145139
enableMessageGroupingByUser?: boolean;

0 commit comments

Comments
 (0)