Page MenuHomePhabricator

D11618.id39325.diff
No OneTemporary

D11618.id39325.diff

diff --git a/lib/reducers/message-reducer.test.js b/lib/reducers/message-reducer.test.js
--- a/lib/reducers/message-reducer.test.js
+++ b/lib/reducers/message-reducer.test.js
@@ -296,6 +296,7 @@
threadHashes: {},
syncedMetadata: {},
auxUserInfos: {},
+ threadActivityStore: {},
},
},
{
diff --git a/lib/reducers/thread-activity-reducer.js b/lib/reducers/thread-activity-reducer.js
--- a/lib/reducers/thread-activity-reducer.js
+++ b/lib/reducers/thread-activity-reducer.js
@@ -2,6 +2,7 @@
import invariant from 'invariant';
+import { setClientDBStoreActionType } from '../actions/client-db-store-actions.js';
import { messageStorePruneActionType } from '../actions/message-actions.js';
import {
changeThreadMemberRolesActionTypes,
@@ -21,6 +22,7 @@
threadActivityStoreOpsHandlers,
type ThreadActivityStoreOperation,
} from '../ops/thread-activity-store-ops.js';
+import { isWebPlatform } from '../types/device-types.js';
import type { BaseAction } from '../types/redux-types.js';
import { incrementalStateSyncActionType } from '../types/socket-types.js';
import type { ThreadActivityStore } from '../types/thread-activity-types.js';
@@ -28,6 +30,34 @@
import { updateTypes } from '../types/update-types-enum.js';
import type { ClientUpdateInfo } from '../types/update-types.js';
import { processUpdatesActionType } from '../types/update-types.js';
+import { getConfig } from '../utils/config.js';
+import { getMessageForException } from '../utils/errors.js';
+import { assertObjectsAreEqual } from '../utils/objects.js';
+
+function assertThreadActivityStoresAreEqual(
+ processedThreadActivityStore: ThreadActivityStore,
+ expectedThreadActivityStore: ThreadActivityStore,
+ location: string,
+ onStateDifference?: (message: string) => mixed,
+) {
+ try {
+ assertObjectsAreEqual(
+ processedThreadActivityStore,
+ expectedThreadActivityStore,
+ `ThreadActivityStore - ${location}`,
+ );
+ } catch (e) {
+ console.log(
+ 'Error processing ThreadActivityStore ops',
+ processedThreadActivityStore,
+ expectedThreadActivityStore,
+ );
+ const message = `Error processing ThreadActivityStore ops ${
+ getMessageForException(e) ?? '{no exception message}'
+ }`;
+ onStateDifference?.(message);
+ }
+}
const { processStoreOperations: processStoreOps } =
threadActivityStoreOpsHandlers;
@@ -35,6 +65,7 @@
function reduceThreadActivity(
state: ThreadActivityStore,
action: BaseAction,
+ onStateDifference?: (message: string) => mixed,
): {
+threadActivityStore: ThreadActivityStore,
+threadActivityStoreOperations: $ReadOnlyArray<ThreadActivityStoreOperation>,
@@ -171,6 +202,20 @@
threadActivityStore: processStoreOps(state, [removeOperation]),
threadActivityStoreOperations: [removeOperation],
};
+ } else if (action.type === setClientDBStoreActionType) {
+ if (!isWebPlatform(getConfig().platformDetails.platform)) {
+ assertThreadActivityStoresAreEqual(
+ action.payload.threadActivityStore ?? {},
+ state,
+ action.type,
+ onStateDifference,
+ );
+ }
+
+ return {
+ threadActivityStore: state,
+ threadActivityStoreOperations: [],
+ };
}
return {
threadActivityStore: state,
diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -15,6 +15,7 @@
} from './message-types.js';
import type { ClientReportCreationRequest } from './report-types.js';
import type { SyncedMetadata } from './synced-metadata-types.js';
+import type { ThreadActivityStore } from './thread-activity-types.js';
import type { ClientDBThreadInfo, ThreadStore } from './thread-types.js';
import type { UserInfos } from './user-types.js';
import type {
@@ -121,4 +122,5 @@
+threadHashes: ?ThreadHashes,
+syncedMetadata: ?SyncedMetadata,
+auxUserInfos: ?AuxUserInfos,
+ +threadActivityStore: ?ThreadActivityStore,
};
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
@@ -14,6 +14,7 @@
import { keyserverStoreOpsHandlers } from 'lib/ops/keyserver-store-ops.js';
import { reportStoreOpsHandlers } from 'lib/ops/report-store-ops.js';
import { syncedMetadataStoreOpsHandlers } from 'lib/ops/synced-metadata-store-ops.js';
+import { threadActivityStoreOpsHandlers } from 'lib/ops/thread-activity-store-ops.js';
import { threadStoreOpsHandlers } from 'lib/ops/thread-store-ops.js';
import { userStoreOpsHandlers } from 'lib/ops/user-store-ops.js';
import { isLoggedIn } from 'lib/selectors/user-selectors.js';
@@ -238,6 +239,7 @@
integrityThreadHashes,
syncedMetadata,
auxUserInfos,
+ threadActivityEntries,
} = await commCoreModule.getClientDBStore();
const threadInfosFromDB =
threadStoreOpsHandlers.translateClientDBData(threads);
@@ -256,7 +258,10 @@
syncedMetadataStoreOpsHandlers.translateClientDBData(syncedMetadata);
const auxUserInfosFromDB =
auxUserStoreOpsHandlers.translateClientDBData(auxUserInfos);
-
+ const threadActivityStoreFromDB =
+ threadActivityStoreOpsHandlers.translateClientDBData(
+ threadActivityEntries,
+ );
dispatch({
type: setClientDBStoreActionType,
payload: {
@@ -272,6 +277,7 @@
threadHashes: threadHashesFromDB,
syncedMetadata: syncedMetadataFromDB,
auxUserInfos: auxUserInfosFromDB,
+ threadActivityStore: threadActivityStoreFromDB,
},
});
} catch (setStoreException) {
diff --git a/web/shared-worker/utils/store.js b/web/shared-worker/utils/store.js
--- a/web/shared-worker/utils/store.js
+++ b/web/shared-worker/utils/store.js
@@ -36,6 +36,7 @@
threadHashes: null,
syncedMetadata: null,
auxUserInfos: null,
+ threadActivityStore: null,
};
const data = await sharedWorker.schedule({
type: workerRequestMessageTypes.GET_CLIENT_STORE,
@@ -123,6 +124,17 @@
messageStoreThreads: data.store.messageStoreThreads,
};
}
+ if (
+ data?.store?.threadActivityEntries &&
+ data.store.threadActivityEntries.length > 0
+ ) {
+ result = {
+ ...result,
+ threadActivityStore: threadActivityStoreOpsHandlers.translateClientDBData(
+ data.store.threadActivityEntries,
+ ),
+ };
+ }
return result;
}

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 5:21 AM (20 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2610044
Default Alt Text
D11618.id39325.diff (6 KB)

Event Timeline