Page MenuHomePhabricator

D11618.id39174.diff
No OneTemporary

D11618.id39174.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,
@@ -28,6 +29,33 @@
import { updateTypes } from '../types/update-types-enum.js';
import type { ClientUpdateInfo } from '../types/update-types.js';
import { processUpdatesActionType } from '../types/update-types.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 +63,7 @@
function reduceThreadActivity(
state: ThreadActivityStore,
action: BaseAction,
+ onStateDifference?: (message: string) => mixed,
): {
+threadActivityStore: ThreadActivityStore,
+threadActivityStoreOperations: $ReadOnlyArray<ThreadActivityStoreOperation>,
@@ -171,6 +200,17 @@
threadActivityStore: processStoreOps(state, [removeOperation]),
threadActivityStoreOperations: [removeOperation],
};
+ } else if (action.type === setClientDBStoreActionType) {
+ 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
@@ -13,6 +13,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';
@@ -210,6 +211,7 @@
integrityThreadHashes,
syncedMetadata,
auxUserInfos,
+ threadActivityEntries,
} = await commCoreModule.getClientDBStore();
const threadInfosFromDB =
threadStoreOpsHandlers.translateClientDBData(threads);
@@ -228,7 +230,10 @@
syncedMetadataStoreOpsHandlers.translateClientDBData(syncedMetadata);
const auxUserInfosFromDB =
auxUserStoreOpsHandlers.translateClientDBData(auxUserInfos);
-
+ const threadActivityStoreFromDB =
+ threadActivityStoreOpsHandlers.translateClientDBData(
+ threadActivityEntries,
+ );
dispatch({
type: setClientDBStoreActionType,
payload: {
@@ -244,6 +249,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:46 AM (20 h, 50 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2610437
Default Alt Text
D11618.id39174.diff (5 KB)

Event Timeline