Skip to content

Commit b6df565

Browse files
Fixing message status issue
1 parent 4912ea4 commit b6df565

File tree

2 files changed

+27
-9
lines changed

2 files changed

+27
-9
lines changed

src/components/Message/Message.tsx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,16 +374,39 @@ const areEqual = <
374374
prevProps: MessagePropsWithContext<At, Ch, Co, Ev, Me, Re, Us>,
375375
nextProps: MessagePropsWithContext<At, Ch, Co, Ev, Me, Re, Us>,
376376
) => {
377-
const { message: prevMessage } = prevProps;
378-
const { message: nextMessage } = nextProps;
377+
const {
378+
lastReceivedId: prevLastReceivedId,
379+
message: prevMessage,
380+
readBy: prevReadBy,
381+
} = prevProps;
382+
const {
383+
lastReceivedId: nextLastReceivedId,
384+
message: nextMessage,
385+
readBy: nextReadBy,
386+
} = nextProps;
379387

380388
const messageEqual = prevMessage.updated_at === nextMessage.updated_at;
389+
390+
const lastReceivedIdEqual =
391+
prevLastReceivedId === nextLastReceivedId ||
392+
(prevLastReceivedId !== nextMessage.id &&
393+
nextLastReceivedId !== nextMessage.id &&
394+
prevLastReceivedId !== prevMessage.id &&
395+
nextLastReceivedId !== prevMessage.id);
396+
381397
const reactionsEqual =
382398
prevMessage.latest_reactions?.length ===
383399
nextMessage.latest_reactions?.length;
384400
const repliesEqual = prevMessage.reply_count === nextMessage.reply_count;
385401

386-
return messageEqual && reactionsEqual && repliesEqual;
402+
const readByEqual = prevReadBy === nextReadBy;
403+
return (
404+
messageEqual &&
405+
reactionsEqual &&
406+
repliesEqual &&
407+
lastReceivedIdEqual &&
408+
readByEqual
409+
);
387410
};
388411

389412
const MemoizedDefaultMessage = React.memo(

src/components/Message/MessageSimple/MessageStatus.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,7 @@ export const MessageStatus = <
9999
);
100100
}
101101

102-
if (
103-
readBy.length !== 0 &&
104-
!threadList &&
105-
message.id === lastReceivedId &&
106-
!justReadByMe
107-
) {
102+
if (readBy.length !== 0 && !threadList && !justReadByMe) {
108103
const lastReadUser = readBy.filter(
109104
(item) => item.id !== client.user?.id,
110105
)[0];

0 commit comments

Comments
 (0)