Fix cache invalidation for conversation preload
This commit is contained in:
parent
a1a15193c6
commit
90faa0d90e
1 changed files with 11 additions and 10 deletions
|
@ -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]])
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue