Timeline: Use messageChangeCounter to mark messages read less often

This commit is contained in:
Scott Nonnenberg 2022-05-11 15:41:45 -07:00 committed by GitHub
parent 69d0ed3309
commit af2c884c9f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 162 additions and 6 deletions

View file

@ -244,6 +244,7 @@ export type MessageLookupType = {
};
export type ConversationMessageType = {
isNearBottom?: boolean;
messageChangeCounter: number;
messageIds: Array<string>;
messageLoadingState?: undefined | TimelineMessageLoadingState;
metrics: MessageMetricsType;
@ -2502,8 +2503,18 @@ export function reducer(
return state;
}
const toIncrement = data.reactions?.length ? 1 : 0;
return {
...state,
messagesByConversation: {
...state.messagesByConversation,
[conversationId]: {
...existingConversation,
messageChangeCounter:
(existingConversation.messageChangeCounter || 0) + toIncrement,
},
},
messagesLookup: {
...state.messagesLookup,
[id]: {
@ -2582,6 +2593,7 @@ export function reducer(
messagesByConversation: {
...messagesByConversation,
[conversationId]: {
messageChangeCounter: 0,
scrollToMessageId,
scrollToMessageCounter: existingConversation
? existingConversation.scrollToMessageCounter + 1