diff --git a/native/redux/persist.js b/native/redux/persist.js --- a/native/redux/persist.js +++ b/native/redux/persist.js @@ -13,8 +13,13 @@ import { unshimMessageStore } from 'lib/shared/unshim-utils'; import { defaultEnabledApps } from 'lib/types/enabled-apps'; import { defaultCalendarFilters } from 'lib/types/filter-types'; -import { messageTypes } from 'lib/types/message-types'; -import type { ClientDBMessageStoreOperation } from 'lib/types/message-types'; +import { + type LocalMessageInfo, + type MessageStore, + messageTypes, + type ClientDBMessageStoreOperation, + type RawMessageInfo, +} from 'lib/types/message-types'; import { defaultConnectionInfo } from 'lib/types/socket-types'; import { translateRawMessageInfoToClientDBMessageInfo } from 'lib/utils/message-ops-utils'; import { convertThreadStoreOperationsToClientDBOperations } from 'lib/utils/thread-ops-utils'; @@ -376,8 +381,22 @@ // this transformation should be executed in the `whitelist` property of the // `config` object that's passed to `createTransform(...)`. // eslint-disable-next-line no-unused-vars +type PersistedThreadMessageInfo = { + +startReached: boolean, + +lastNavigatedTo: number, + +lastPruned: number, +}; +type PersistedMessageStore = { + +local: { +[id: string]: LocalMessageInfo }, + +currentAsOf: number, + +threads: { +[threadID: string]: PersistedThreadMessageInfo }, +}; +type RehydratedMessageStore = $Diff< + MessageStore, + { +messages: { +[id: string]: RawMessageInfo } }, +>; const messageStoreMessagesBlocklistTransform: Transform = createTransform( - state => { + (state: MessageStore): PersistedMessageStore => { const { messages, threads, ...messageStoreSansMessages } = state; // We also do not want to persist `messageStore.threads[ID].messageIDs` // because they can be deterministically computed based on messages we have @@ -389,7 +408,7 @@ } return { ...messageStoreSansMessages, threads: threadsToPersist }; }, - state => { + (state: PersistedMessageStore): RehydratedMessageStore => { const { threads: persistedThreads, ...messageStore } = state; const threads = {}; for (const threadID in persistedThreads) {