Skip to content

Commit 533cf28

Browse files
committed
feat: remove props endOfGroup, firstOfGroup and groupedByUser from MessageProps
1 parent 1b6435c commit 533cf28

2 files changed

Lines changed: 2 additions & 35 deletions

File tree

src/components/Message/types.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,6 @@ export type MessageProps = {
2626
deliveredTo?: UserResponse[];
2727
/** If true, disables the ability for users to quote messages, defaults to false */
2828
disableQuotedMessages?: boolean;
29-
/** When true, the message is the last one in a group sent by a specific user (only used in the `VirtualizedMessageList`) */
30-
endOfGroup?: boolean;
31-
/** When true, the message is the first one in a group sent by a specific user (only used in the `VirtualizedMessageList`) */
32-
firstOfGroup?: boolean;
3329
/** Override the default formatting of the date. This is a function that has access to the original date object, returns a string */
3430
formatDate?: (date: Date) => string;
3531
/** Function that returns the notification text to be displayed when a delete message request fails */
@@ -50,8 +46,6 @@ export type MessageProps = {
5046
getMuteUserSuccessNotification?: (user: UserResponse) => string;
5147
/** Function that returns the notification text to be displayed when a pin message request fails */
5248
getPinMessageErrorNotification?: (message: LocalMessage) => string;
53-
/** If true, group messages sent by each user (only used in the `VirtualizedMessageList`) */
54-
groupedByUser?: boolean;
5549
/** A list of styles to apply to this message, i.e. top, bottom, single */
5650
groupStyles?: GroupStyle[];
5751
/** Whether to highlight and focus the message on load */

src/components/MessageList/VirtualizedMessageListComponents.tsx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import type { ItemProps, ListItem } from 'react-virtuoso';
55

66
import { EmptyStateIndicator as DefaultEmptyStateIndicator } from '../EmptyStateIndicator';
77
import { LoadingIndicator as DefaultLoadingIndicator } from '../Loading';
8-
import { isMessageEdited, Message } from '../Message';
8+
import { Message } from '../Message';
99

1010
import { useComponentContext } from '../../context';
11-
import { getIsFirstUnreadMessage, isDateSeparatorMessage, isIntroMessage } from './utils';
12-
13-
import type { LocalMessage } from 'stream-chat';
1411
import type { GroupStyle, RenderedMessage } from './utils';
12+
import { getIsFirstUnreadMessage, isDateSeparatorMessage, isIntroMessage } from './utils';
1513
import type { VirtuosoContext } from './VirtualizedMessageList';
1614
import type { UnknownType } from '../../types/types';
1715

@@ -131,7 +129,6 @@ export const messageRenderer = (
131129
reactionDetailsSort,
132130
renderText,
133131
returnAllReadData,
134-
shouldGroupByUser,
135132
showAvatar,
136133
sortReactionDetails,
137134
sortReactions,
@@ -161,27 +158,6 @@ export const messageRenderer = (
161158
return MessageSystem ? <MessageSystem message={message} /> : null;
162159
}
163160

164-
const maybePrevMessage = messageList[streamMessageIndex - 1] as
165-
| LocalMessage
166-
| undefined;
167-
const maybeNextMessage = messageList[streamMessageIndex + 1] as
168-
| LocalMessage
169-
| undefined;
170-
const groupedByUser =
171-
shouldGroupByUser &&
172-
streamMessageIndex > 0 &&
173-
message.user?.id === maybePrevMessage?.user?.id;
174-
175-
// FIXME: firstOfGroup & endOfGroup should be derived from groupStyles which apply a more complex logic
176-
const firstOfGroup =
177-
shouldGroupByUser &&
178-
(message.user?.id !== maybePrevMessage?.user?.id ||
179-
(maybePrevMessage && isMessageEdited(maybePrevMessage)));
180-
181-
const endOfGroup =
182-
shouldGroupByUser &&
183-
(message.user?.id !== maybeNextMessage?.user?.id || isMessageEdited(message));
184-
185161
const isFirstUnreadMessage = getIsFirstUnreadMessage({
186162
firstUnreadMessageId,
187163
isFirstMessage: streamMessageIndex === 0,
@@ -204,10 +180,7 @@ export const messageRenderer = (
204180
autoscrollToBottom={virtuosoRef.current?.autoscrollToBottom}
205181
closeReactionSelectorOnClick={closeReactionSelectorOnClick}
206182
deliveredTo={ownMessagesDeliveredToOthers[message.id] || []}
207-
endOfGroup={endOfGroup}
208-
firstOfGroup={firstOfGroup}
209183
formatDate={formatDate}
210-
groupedByUser={groupedByUser}
211184
groupStyles={[messageGroupStyles[message.id] ?? '']}
212185
lastOwnMessage={lastOwnMessage}
213186
lastReceivedId={lastReceivedMessageId}

0 commit comments

Comments
 (0)