Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3374674
D7473.id25229.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D7473.id25229.diff
View Options
diff --git a/lib/reducers/message-reducer.js b/lib/reducers/message-reducer.js
--- a/lib/reducers/message-reducer.js
+++ b/lib/reducers/message-reducer.js
@@ -100,7 +100,10 @@
} from '../types/update-types.js';
import { setNewSessionActionType } from '../utils/action-utils.js';
import { isDev } from '../utils/dev-utils.js';
-import { translateClientDBMessageInfosToRawMessageInfos } from '../utils/message-ops-utils.js';
+import {
+ translateClientDBMessageInfosToRawMessageInfos,
+ translateClientDBThreadMessageInfos,
+} from '../utils/message-ops-utils.js';
import { assertObjectsAreEqual } from '../utils/objects.js';
const PROCESSED_MSG_STORE_INVARIANTS_DISABLED = !isDev;
@@ -1614,6 +1617,26 @@
},
};
} else if (action.type === setClientDBStoreActionType) {
+ const actionPayloadMessageStoreThreads =
+ translateClientDBThreadMessageInfos(action.payload.messageStoreThreads);
+
+ const newThreads = {};
+ for (const threadID in actionPayloadMessageStoreThreads) {
+ newThreads[threadID] = {
+ ...actionPayloadMessageStoreThreads[threadID],
+ messageIDs: messageStore.threads[threadID].messageIDs,
+ };
+ }
+
+ assertMessageStoreThreadsAreEqual(
+ {
+ ...messageStore,
+ threads: newThreads,
+ },
+ messageStore,
+ action.type,
+ );
+
const { messageStoreOperations, messageStore: updatedMessageStore } =
updateMessageStoreWithLatestThreadInfos(messageStore, newThreadInfos);
diff --git a/lib/utils/message-ops-utils.js b/lib/utils/message-ops-utils.js
--- a/lib/utils/message-ops-utils.js
+++ b/lib/utils/message-ops-utils.js
@@ -231,6 +231,28 @@
);
}
+type TranslatedThreadMessageInfos = {
+ [threadID: string]: {
+ startReached: boolean,
+ lastNavigatedTo: number,
+ lastPruned: number,
+ },
+};
+function translateClientDBThreadMessageInfos(
+ clientDBThreadMessageInfo: $ReadOnlyArray<ClientDBThreadMessageInfo>,
+): TranslatedThreadMessageInfos {
+ return Object.fromEntries(
+ clientDBThreadMessageInfo.map((threadInfo: ClientDBThreadMessageInfo) => [
+ threadInfo.id,
+ {
+ startReached: threadInfo.start_reached === '1',
+ lastNavigatedTo: parseInt(threadInfo.last_navigated_to),
+ lastPruned: parseInt(threadInfo.last_pruned),
+ },
+ ]),
+ );
+}
+
function translateThreadMessageInfoToClientDBThreadMessageInfo(
id: string,
threadMessageInfo: ThreadMessageInfo,
@@ -311,4 +333,5 @@
convertMessageStoreOperationsToClientDBOperations,
translateClientDBMediaInfosToMedia,
getPinnedContentFromClientDBMessageInfo,
+ translateClientDBThreadMessageInfos,
};
diff --git a/native/data/sqlite-data-handler.js b/native/data/sqlite-data-handler.js
--- a/native/data/sqlite-data-handler.js
+++ b/native/data/sqlite-data-handler.js
@@ -151,7 +151,7 @@
mediaCacheContext?.evictCache(),
]);
try {
- const { threads, messages, drafts } =
+ const { threads, messages, drafts, messageStoreThreads } =
await commCoreModule.getClientDBStore();
const threadInfosFromDB =
convertClientDBThreadInfosToRawThreadInfos(threads);
@@ -162,6 +162,7 @@
messages,
threadStore: { threadInfos: threadInfosFromDB },
currentUserID: currentLoggedInUserID,
+ messageStoreThreads,
},
});
} catch (setStoreException) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 27, 4:42 PM (22 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2591021
Default Alt Text
D7473.id25229.diff (3 KB)
Attached To
Mode
D7473: [native] retrieve message store threads from SQLite and compare with `redux-persist`
Attached
Detach File
Event Timeline
Log In to Comment