diff --git a/lib/reducers/entry-reducer.js b/lib/reducers/entry-reducer.js --- a/lib/reducers/entry-reducer.js +++ b/lib/reducers/entry-reducer.js @@ -42,6 +42,7 @@ } from '../actions/user-actions.js'; import { setNewSessionActionType } from '../keyserver-conn/keyserver-conn-types.js'; import type { EntryStoreOperation } from '../ops/entries-store-ops.js'; +import { entryStoreOpsHandlers } from '../ops/entries-store-ops.js'; import { entryID } from '../shared/entry-utils.js'; import { stateSyncSpecs } from '../shared/state-sync/state-sync-specs.js'; import { threadInFilterList } from '../shared/thread-utils.js'; @@ -215,26 +216,24 @@ if (Object.keys(newEntryInfos).length === Object.keys(entryInfos).length) { return { - entryStore: { - entryInfos, - daysToEntries, - lastUserInteractionCalendar, - }, + entryStore, entryStoreOperations: [], reportCreationRequests: [], }; } - const newDaysToEntries = filterExistingDaysToEntriesWithNewEntryInfos( - daysToEntries, - newEntryInfos, - ); + const ops = [ + { type: 'remove_all_entries' }, + ...Object.entries(newEntryInfos).map(([id, entry]) => ({ + type: 'replace_entry', + payload: { + id, + entry, + }, + })), + ]; return { - entryStore: { - entryInfos: newEntryInfos, - daysToEntries: newDaysToEntries, - lastUserInteractionCalendar, - }, - entryStoreOperations: [], + entryStore: entryStoreOpsHandlers.processStoreOperations(entryStore, ops), + entryStoreOperations: ops, reportCreationRequests: [], }; } else if (action.type === setNewSessionActionType) { @@ -242,10 +241,6 @@ const newEntryInfos = _pickBy( (entry: RawEntryInfo) => authorizedThreadInfos[entry.threadID], )(entryInfos); - const newDaysToEntries = filterExistingDaysToEntriesWithNewEntryInfos( - daysToEntries, - newEntryInfos, - ); let newLastUserInteractionCalendar = lastUserInteractionCalendar; if ( action.payload.sessionChange.cookieInvalidated && @@ -266,13 +261,22 @@ reportCreationRequests: [], }; } + const ops = [ + { type: 'remove_all_entries' }, + ...Object.entries(newEntryInfos).map(([id, entry]) => ({ + type: 'replace_entry', + payload: { + id, + entry, + }, + })), + ]; return { entryStore: { - entryInfos: newEntryInfos, - daysToEntries: newDaysToEntries, + ...entryStoreOpsHandlers.processStoreOperations(entryStore, ops), lastUserInteractionCalendar: newLastUserInteractionCalendar, }, - entryStoreOperations: [], + entryStoreOperations: ops, reportCreationRequests: [], }; } else if (action.type === fetchEntriesActionTypes.success) {