Fix cache invalidation for conversation preload

This commit is contained in:
Fedor Indutny 2024-09-24 16:12:28 -07:00 committed by GitHub
parent a1a15193c6
commit 90faa0d90e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -5635,7 +5635,7 @@ export function reducer(
if (action.type === MESSAGE_EXPIRED) {
return maybeUpdateSelectedMessageForDetails(
{ messageId: action.payload.id, targetedMessageForDetails: undefined },
state
dropPreloadData(state)
);
}
@ -5949,20 +5949,21 @@ export function reducer(
if (action.type === 'MESSAGES_ADDED') {
const { conversationId, isActive, isJustSent, isNewMessage, messages } =
action.payload;
const { messagesByConversation, messagesLookup } = state;
const existingConversation = messagesByConversation[conversationId];
if (!existingConversation) {
return state;
}
let { newest, oldest, oldestUnseen, totalUnseen } =
existingConversation.metrics;
if (messages.length < 1) {
return state;
}
const { messagesByConversation, messagesLookup } = state;
const existingConversation = messagesByConversation[conversationId];
if (!existingConversation) {
return dropPreloadData(state);
}
let { newest, oldest, oldestUnseen, totalUnseen } =
existingConversation.metrics;
const lookup = fromPairs(
existingConversation.messageIds.map(id => [id, messagesLookup[id]])
);