Message List: Fix stuck unread divider before service notification
This commit is contained in:
parent
cf2db92c61
commit
250296ee52
@ -77,6 +77,7 @@ type StateProps = {
|
|||||||
isBot?: boolean;
|
isBot?: boolean;
|
||||||
messageIds?: number[];
|
messageIds?: number[];
|
||||||
messagesById?: Record<number, ApiMessage>;
|
messagesById?: Record<number, ApiMessage>;
|
||||||
|
isUnread?: boolean;
|
||||||
firstUnreadId?: number;
|
firstUnreadId?: number;
|
||||||
isViewportNewest?: boolean;
|
isViewportNewest?: boolean;
|
||||||
isRestricted?: boolean;
|
isRestricted?: boolean;
|
||||||
@ -124,6 +125,7 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
messageIds,
|
messageIds,
|
||||||
messagesById,
|
messagesById,
|
||||||
firstUnreadId,
|
firstUnreadId,
|
||||||
|
isUnread,
|
||||||
isViewportNewest,
|
isViewportNewest,
|
||||||
threadFirstMessageId,
|
threadFirstMessageId,
|
||||||
isRestricted,
|
isRestricted,
|
||||||
@ -172,11 +174,12 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
}, [firstUnreadId]);
|
}, [firstUnreadId]);
|
||||||
|
|
||||||
// Updated only once when messages are loaded (as we want the unread divider to keep its position)
|
// Updated only once when messages are loaded (as we want the unread divider to keep its position)
|
||||||
|
const withUnreadDivider = areMessagesLoaded && isUnread;
|
||||||
useOnChange(() => {
|
useOnChange(() => {
|
||||||
if (areMessagesLoaded) {
|
if (withUnreadDivider) {
|
||||||
memoUnreadDividerBeforeIdRef.current = memoFirstUnreadIdRef.current;
|
memoUnreadDividerBeforeIdRef.current = memoFirstUnreadIdRef.current;
|
||||||
}
|
}
|
||||||
}, [areMessagesLoaded]);
|
}, [withUnreadDivider]);
|
||||||
|
|
||||||
useOnChange(() => {
|
useOnChange(() => {
|
||||||
memoFocusingIdRef.current = focusingId;
|
memoFocusingIdRef.current = focusingId;
|
||||||
@ -503,7 +506,7 @@ const MessageList: FC<OwnProps & StateProps & DispatchProps> = ({
|
|||||||
messageIds={messageIds || [lastMessage!.id]}
|
messageIds={messageIds || [lastMessage!.id]}
|
||||||
messageGroups={messageGroups || groupMessages([lastMessage!])}
|
messageGroups={messageGroups || groupMessages([lastMessage!])}
|
||||||
isViewportNewest={Boolean(isViewportNewest)}
|
isViewportNewest={Boolean(isViewportNewest)}
|
||||||
isUnread={Boolean(firstUnreadId)}
|
isUnread={Boolean(isUnread)}
|
||||||
withUsers={withUsers}
|
withUsers={withUsers}
|
||||||
noAvatars={noAvatars}
|
noAvatars={noAvatars}
|
||||||
containerRef={containerRef}
|
containerRef={containerRef}
|
||||||
@ -578,6 +581,7 @@ export default memo(withGlobal<OwnProps>(
|
|||||||
isBot: Boolean(chatBot),
|
isBot: Boolean(chatBot),
|
||||||
messageIds,
|
messageIds,
|
||||||
messagesById,
|
messagesById,
|
||||||
|
isUnread: Boolean(chat.unreadCount),
|
||||||
firstUnreadId: selectFirstUnreadId(global, chatId, threadId),
|
firstUnreadId: selectFirstUnreadId(global, chatId, threadId),
|
||||||
isViewportNewest: type !== 'thread' || selectIsViewportNewest(global, chatId, threadId),
|
isViewportNewest: type !== 'thread' || selectIsViewportNewest(global, chatId, threadId),
|
||||||
threadFirstMessageId: selectFirstMessageId(global, chatId, threadId),
|
threadFirstMessageId: selectFirstMessageId(global, chatId, threadId),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user