Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3397511
D5001.id16313.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D5001.id16313.diff
View Options
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,12 +381,41 @@
// 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 => {
- const { messages, ...messageStoreSansMessages } = state;
- return messageStoreSansMessages;
+ (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
+ // from SQLite
+ const threadsToPersist = {};
+ for (const threadID in threads) {
+ const { messageIDs, ...threadsData } = threads[threadID];
+ threadsToPersist[threadID] = threadsData;
+ }
+ return { ...messageStoreSansMessages, threads: threadsToPersist };
+ },
+ (state: PersistedMessageStore): RehydratedMessageStore => {
+ const { threads: persistedThreads, ...messageStore } = state;
+ const threads = {};
+ for (const threadID in persistedThreads) {
+ threads[threadID] = { ...persistedThreads[threadID], messageIDs: [] };
+ }
+ return { ...messageStore, threads };
},
- null,
{ whitelist: ['messageStore'] },
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 2, 5:49 PM (20 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2608238
Default Alt Text
D5001.id16313.diff (2 KB)
Attached To
Mode
D5001: [native] Stop persisting `messageIDs` in `messageStore.threads`
Attached
Detach File
Event Timeline
Log In to Comment