Fix cache invalidation for conversation preload

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2024-09-24 19:33:58 -05:00 committed by GitHub
parent 72b139a278
commit 64469f95c7
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) { if (action.type === MESSAGE_EXPIRED) {
return maybeUpdateSelectedMessageForDetails( return maybeUpdateSelectedMessageForDetails(
{ messageId: action.payload.id, targetedMessageForDetails: undefined }, { messageId: action.payload.id, targetedMessageForDetails: undefined },
state dropPreloadData(state)
); );
} }
@ -5949,20 +5949,21 @@ export function reducer(
if (action.type === 'MESSAGES_ADDED') { if (action.type === 'MESSAGES_ADDED') {
const { conversationId, isActive, isJustSent, isNewMessage, messages } = const { conversationId, isActive, isJustSent, isNewMessage, messages } =
action.payload; 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) { if (messages.length < 1) {
return state; 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( const lookup = fromPairs(
existingConversation.messageIds.map(id => [id, messagesLookup[id]]) existingConversation.messageIds.map(id => [id, messagesLookup[id]])
); );