Page MenuHomePhabricator

D11936.id39925.diff
No OneTemporary

D11936.id39925.diff

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
@@ -67,17 +67,17 @@
} from '../ops/user-store-ops.js';
export type StoreOperations = {
- +draftStoreOperations: $ReadOnlyArray<DraftStoreOperation>,
- +threadStoreOperations: $ReadOnlyArray<ThreadStoreOperation>,
- +messageStoreOperations: $ReadOnlyArray<MessageStoreOperation>,
- +reportStoreOperations: $ReadOnlyArray<ReportStoreOperation>,
- +userStoreOperations: $ReadOnlyArray<UserStoreOperation>,
- +keyserverStoreOperations: $ReadOnlyArray<KeyserverStoreOperation>,
- +communityStoreOperations: $ReadOnlyArray<CommunityStoreOperation>,
- +integrityStoreOperations: $ReadOnlyArray<IntegrityStoreOperation>,
- +syncedMetadataStoreOperations: $ReadOnlyArray<ClientDBSyncedMetadataStoreOperation>,
- +auxUserStoreOperations: $ReadOnlyArray<AuxUserStoreOperation>,
- +threadActivityStoreOperations: $ReadOnlyArray<ThreadActivityStoreOperation>,
+ +draftStoreOperations?: $ReadOnlyArray<DraftStoreOperation>,
+ +threadStoreOperations?: $ReadOnlyArray<ThreadStoreOperation>,
+ +messageStoreOperations?: $ReadOnlyArray<MessageStoreOperation>,
+ +reportStoreOperations?: $ReadOnlyArray<ReportStoreOperation>,
+ +userStoreOperations?: $ReadOnlyArray<UserStoreOperation>,
+ +keyserverStoreOperations?: $ReadOnlyArray<KeyserverStoreOperation>,
+ +communityStoreOperations?: $ReadOnlyArray<CommunityStoreOperation>,
+ +integrityStoreOperations?: $ReadOnlyArray<IntegrityStoreOperation>,
+ +syncedMetadataStoreOperations?: $ReadOnlyArray<ClientDBSyncedMetadataStoreOperation>,
+ +auxUserStoreOperations?: $ReadOnlyArray<AuxUserStoreOperation>,
+ +threadActivityStoreOperations?: $ReadOnlyArray<ThreadActivityStoreOperation>,
};
export type ClientDBStoreOperations = {
diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js
--- a/native/redux/redux-setup.js
+++ b/native/redux/redux-setup.js
@@ -299,40 +299,18 @@
state = baseReducerResult.state;
const { storeOperations } = baseReducerResult;
- const {
- draftStoreOperations,
- threadStoreOperations,
- messageStoreOperations,
- reportStoreOperations,
- userStoreOperations,
- keyserverStoreOperations,
- communityStoreOperations,
- integrityStoreOperations,
- syncedMetadataStoreOperations,
- auxUserStoreOperations,
- threadActivityStoreOperations,
- } = storeOperations;
const fixUnreadActiveThreadResult = fixUnreadActiveThread(state, action);
state = fixUnreadActiveThreadResult.state;
const threadStoreOperationsWithUnreadFix = [
- ...threadStoreOperations,
+ ...(storeOperations.threadStoreOperations ?? []),
...fixUnreadActiveThreadResult.threadStoreOperations,
];
const ops = {
- draftStoreOperations,
- messageStoreOperations,
+ ...storeOperations,
threadStoreOperations: threadStoreOperationsWithUnreadFix,
- reportStoreOperations,
- userStoreOperations,
- keyserverStoreOperations,
- communityStoreOperations,
- integrityStoreOperations,
- syncedMetadataStoreOperations,
- auxUserStoreOperations,
- threadActivityStoreOperations,
};
state = {
...state,
diff --git a/native/redux/redux-utils.js b/native/redux/redux-utils.js
--- a/native/redux/redux-utils.js
+++ b/native/redux/redux-utils.js
@@ -47,30 +47,40 @@
} = storeOperations;
const convertedThreadStoreOperations =
- threadStoreOpsHandlers.convertOpsToClientDBOps(threadStoreOperations);
+ threadStoreOpsHandlers.convertOpsToClientDBOps(threadStoreOperations ?? []);
const convertedMessageStoreOperations =
- messageStoreOpsHandlers.convertOpsToClientDBOps(messageStoreOperations);
+ messageStoreOpsHandlers.convertOpsToClientDBOps(
+ messageStoreOperations ?? [],
+ );
const convertedReportStoreOperations =
- reportStoreOpsHandlers.convertOpsToClientDBOps(reportStoreOperations);
+ reportStoreOpsHandlers.convertOpsToClientDBOps(reportStoreOperations ?? []);
const convertedUserStoreOperations =
- userStoreOpsHandlers.convertOpsToClientDBOps(userStoreOperations);
+ userStoreOpsHandlers.convertOpsToClientDBOps(userStoreOperations ?? []);
const convertedKeyserverStoreOperations =
- keyserverStoreOpsHandlers.convertOpsToClientDBOps(keyserverStoreOperations);
+ keyserverStoreOpsHandlers.convertOpsToClientDBOps(
+ keyserverStoreOperations ?? [],
+ );
const convertedCommunityStoreOperations =
- communityStoreOpsHandlers.convertOpsToClientDBOps(communityStoreOperations);
+ communityStoreOpsHandlers.convertOpsToClientDBOps(
+ communityStoreOperations ?? [],
+ );
const convertedSyncedMetadataStoreOperations =
syncedMetadataStoreOpsHandlers.convertOpsToClientDBOps(
- syncedMetadataStoreOperations,
+ syncedMetadataStoreOperations ?? [],
);
const keyserversToRemoveFromNotifsStore =
- getKeyserversToRemoveFromNotifsStore(keyserverStoreOperations);
+ getKeyserversToRemoveFromNotifsStore(keyserverStoreOperations ?? []);
const convertedIntegrityStoreOperations =
- integrityStoreOpsHandlers.convertOpsToClientDBOps(integrityStoreOperations);
+ integrityStoreOpsHandlers.convertOpsToClientDBOps(
+ integrityStoreOperations ?? [],
+ );
const convertedAuxUserStoreOperations =
- auxUserStoreOpsHandlers.convertOpsToClientDBOps(auxUserStoreOperations);
+ auxUserStoreOpsHandlers.convertOpsToClientDBOps(
+ auxUserStoreOperations ?? [],
+ );
const convertedThreadActivityStoreOperations =
threadActivityStoreOpsHandlers.convertOpsToClientDBOps(
- threadActivityStoreOperations,
+ threadActivityStoreOperations ?? [],
);
try {
@@ -96,7 +106,7 @@
auxUserStoreOperations: convertedAuxUserStoreOperations,
threadActivityStoreOperations: convertedThreadActivityStoreOperations,
};
- if (values(dbOps).some(ops => ops.length > 0)) {
+ if (values(dbOps).some(ops => ops && ops.length > 0)) {
promises.push(commCoreModule.processDBStoreOperations(dbOps));
}
await Promise.all(promises);
diff --git a/web/redux/redux-setup.js b/web/redux/redux-setup.js
--- a/web/redux/redux-setup.js
+++ b/web/redux/redux-setup.js
@@ -157,19 +157,7 @@
function reducer(oldState: AppState | void, action: Action): AppState {
invariant(oldState, 'should be set');
let state = oldState;
- let storeOperations: StoreOperations = {
- draftStoreOperations: [],
- threadStoreOperations: [],
- messageStoreOperations: [],
- reportStoreOperations: [],
- userStoreOperations: [],
- keyserverStoreOperations: [],
- communityStoreOperations: [],
- integrityStoreOperations: [],
- syncedMetadataStoreOperations: [],
- auxUserStoreOperations: [],
- threadActivityStoreOperations: [],
- };
+ let storeOperations: StoreOperations = {};
if (
(action.type === setNewSessionActionType &&
@@ -237,7 +225,7 @@
return validateStateAndQueueOpsProcessing(action, oldState, newState, {
...storeOperations,
keyserverStoreOperations: [
- ...storeOperations.keyserverStoreOperations,
+ ...(storeOperations.keyserverStoreOperations ?? []),
...replaceOperations,
],
});
@@ -307,7 +295,7 @@
storeOperations = {
...storeOperations,
keyserverStoreOperations: [
- ...storeOperations.keyserverStoreOperations,
+ ...(storeOperations.keyserverStoreOperations ?? []),
replaceOperation,
],
};
@@ -375,8 +363,8 @@
storeOperations = {
...baseReducerResult.storeOperations,
keyserverStoreOperations: [
- ...storeOperations.keyserverStoreOperations,
- ...baseReducerResult.storeOperations.keyserverStoreOperations,
+ ...(storeOperations.keyserverStoreOperations ?? []),
+ ...(baseReducerResult.storeOperations.keyserverStoreOperations ?? []),
],
};
}
@@ -516,7 +504,7 @@
storeOperations = {
...storeOperations,
threadActivityStoreOperations: [
- ...storeOperations.threadActivityStoreOperations,
+ ...(storeOperations.threadActivityStoreOperations ?? []),
replaceOperation,
],
};
@@ -533,7 +521,7 @@
storeOperations = {
...storeOperations,
threadStoreOperations: [
- ...storeOperations.threadStoreOperations,
+ ...(storeOperations.threadStoreOperations ?? []),
...updateActiveThreadOps,
],
};
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
@@ -159,35 +159,47 @@
const canUseDatabase = canUseDatabaseOnWeb(userID);
const convertedThreadStoreOperations = canUseDatabase
- ? threadStoreOpsHandlers.convertOpsToClientDBOps(threadStoreOperations)
+ ? threadStoreOpsHandlers.convertOpsToClientDBOps(
+ threadStoreOperations ?? [],
+ )
: [];
const convertedReportStoreOperations =
- reportStoreOpsHandlers.convertOpsToClientDBOps(reportStoreOperations);
+ reportStoreOpsHandlers.convertOpsToClientDBOps(reportStoreOperations ?? []);
const convertedKeyserverStoreOperations =
- keyserverStoreOpsHandlers.convertOpsToClientDBOps(keyserverStoreOperations);
+ keyserverStoreOpsHandlers.convertOpsToClientDBOps(
+ keyserverStoreOperations ?? [],
+ );
const convertedCommunityStoreOperations =
- communityStoreOpsHandlers.convertOpsToClientDBOps(communityStoreOperations);
+ communityStoreOpsHandlers.convertOpsToClientDBOps(
+ communityStoreOperations ?? [],
+ );
const convertedIntegrityStoreOperations =
- integrityStoreOpsHandlers.convertOpsToClientDBOps(integrityStoreOperations);
+ integrityStoreOpsHandlers.convertOpsToClientDBOps(
+ integrityStoreOperations ?? [],
+ );
const convertedSyncedMetadataStoreOperations =
syncedMetadataStoreOpsHandlers.convertOpsToClientDBOps(
- syncedMetadataStoreOperations,
+ syncedMetadataStoreOperations ?? [],
);
const convertedAuxUserStoreOperations =
- auxUserStoreOpsHandlers.convertOpsToClientDBOps(auxUserStoreOperations);
+ auxUserStoreOpsHandlers.convertOpsToClientDBOps(
+ auxUserStoreOperations ?? [],
+ );
const convertedUserStoreOperations =
- userStoreOpsHandlers.convertOpsToClientDBOps(userStoreOperations);
+ userStoreOpsHandlers.convertOpsToClientDBOps(userStoreOperations ?? []);
const convertedMessageStoreOperations =
- messageStoreOpsHandlers.convertOpsToClientDBOps(messageStoreOperations);
+ messageStoreOpsHandlers.convertOpsToClientDBOps(
+ messageStoreOperations ?? [],
+ );
const convertedThreadActivityStoreOperations =
threadActivityStoreOpsHandlers.convertOpsToClientDBOps(
- threadActivityStoreOperations,
+ threadActivityStoreOperations ?? [],
);
if (
convertedThreadStoreOperations.length === 0 &&
convertedReportStoreOperations.length === 0 &&
- draftStoreOperations.length === 0 &&
+ (!draftStoreOperations || draftStoreOperations.length === 0) &&
convertedKeyserverStoreOperations.length === 0 &&
convertedCommunityStoreOperations.length === 0 &&
convertedIntegrityStoreOperations.length === 0 &&

File Metadata

Mime Type
text/plain
Expires
Sun, Dec 22, 10:01 PM (15 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2692735
Default Alt Text
D11936.id39925.diff (11 KB)

Event Timeline