Page MenuHomePhabricator

D11936.id40154.diff
No OneTemporary

D11936.id40154.diff

diff --git a/lib/ops/aux-user-store-ops.js b/lib/ops/aux-user-store-ops.js
--- a/lib/ops/aux-user-store-ops.js
+++ b/lib/ops/aux-user-store-ops.js
@@ -90,8 +90,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<AuxUserStoreOperation>,
+ ops: ?$ReadOnlyArray<AuxUserStoreOperation>,
): $ReadOnlyArray<ClientDBAuxUserStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops.map(operation => {
if (
operation.type === 'remove_aux_user_infos' ||
diff --git a/lib/ops/base-ops.js b/lib/ops/base-ops.js
--- a/lib/ops/base-ops.js
+++ b/lib/ops/base-ops.js
@@ -12,7 +12,7 @@
ops: $ReadOnlyArray<Operation>,
) => Store,
convertOpsToClientDBOps: (
- ops: $ReadOnlyArray<Operation>,
+ ops: ?$ReadOnlyArray<Operation>,
) => $ReadOnlyArray<ClientDBOperation>,
translateClientDBData: (data: $ReadOnlyArray<ClientDBDataType>) => DataType,
};
diff --git a/lib/ops/community-store-ops.js b/lib/ops/community-store-ops.js
--- a/lib/ops/community-store-ops.js
+++ b/lib/ops/community-store-ops.js
@@ -90,8 +90,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<CommunityStoreOperation>,
+ ops: ?$ReadOnlyArray<CommunityStoreOperation>,
): $ReadOnlyArray<ClientDBCommunityStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops.map(operation => {
if (
operation.type === 'remove_communities' ||
diff --git a/lib/ops/integrity-store-ops.js b/lib/ops/integrity-store-ops.js
--- a/lib/ops/integrity-store-ops.js
+++ b/lib/ops/integrity-store-ops.js
@@ -82,8 +82,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<IntegrityStoreOperation>,
+ ops: ?$ReadOnlyArray<IntegrityStoreOperation>,
): $ReadOnlyArray<ClientDBIntegrityStoreOperation> {
+ if (!ops) {
+ return [];
+ }
const convertedOperations = ops.map(integrityStoreOperation => {
if (
integrityStoreOperation.type === 'remove_all_integrity_thread_hashes' ||
diff --git a/lib/ops/keyserver-store-ops.js b/lib/ops/keyserver-store-ops.js
--- a/lib/ops/keyserver-store-ops.js
+++ b/lib/ops/keyserver-store-ops.js
@@ -139,8 +139,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<KeyserverStoreOperation>,
+ ops: ?$ReadOnlyArray<KeyserverStoreOperation>,
): $ReadOnlyArray<ClientDBKeyserverStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops.map(operation => {
if (
operation.type === 'remove_keyservers' ||
diff --git a/lib/ops/message-store-ops.js b/lib/ops/message-store-ops.js
--- a/lib/ops/message-store-ops.js
+++ b/lib/ops/message-store-ops.js
@@ -143,8 +143,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<MessageStoreOperation>,
+ ops: ?$ReadOnlyArray<MessageStoreOperation>,
): $ReadOnlyArray<ClientDBMessageStoreOperation> {
+ if (!ops) {
+ return [];
+ }
const convertedOperations = ops.map(messageStoreOperation => {
if (messageStoreOperation.type === 'replace') {
return {
diff --git a/lib/ops/report-store-ops.js b/lib/ops/report-store-ops.js
--- a/lib/ops/report-store-ops.js
+++ b/lib/ops/report-store-ops.js
@@ -88,8 +88,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<ReportStoreOperation>,
+ ops: ?$ReadOnlyArray<ReportStoreOperation>,
): $ReadOnlyArray<ClientDBReportStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops.map(operation => {
if (
operation.type === 'remove_reports' ||
diff --git a/lib/ops/synced-metadata-store-ops.js b/lib/ops/synced-metadata-store-ops.js
--- a/lib/ops/synced-metadata-store-ops.js
+++ b/lib/ops/synced-metadata-store-ops.js
@@ -77,8 +77,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<SyncedMetadataStoreOperation>,
+ ops: ?$ReadOnlyArray<SyncedMetadataStoreOperation>,
): $ReadOnlyArray<ClientDBSyncedMetadataStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops;
},
diff --git a/lib/ops/thread-activity-store-ops.js b/lib/ops/thread-activity-store-ops.js
--- a/lib/ops/thread-activity-store-ops.js
+++ b/lib/ops/thread-activity-store-ops.js
@@ -94,8 +94,11 @@
return processedThreadActivityStore;
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<ThreadActivityStoreOperation>,
+ ops: ?$ReadOnlyArray<ThreadActivityStoreOperation>,
): $ReadOnlyArray<ClientDBThreadActivityStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops.map(threadActivityStoreOperation => {
if (
threadActivityStoreOperation.type ===
diff --git a/lib/ops/thread-store-ops.js b/lib/ops/thread-store-ops.js
--- a/lib/ops/thread-store-ops.js
+++ b/lib/ops/thread-store-ops.js
@@ -71,8 +71,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<ThreadStoreOperation>,
+ ops: ?$ReadOnlyArray<ThreadStoreOperation>,
): $ReadOnlyArray<ClientDBThreadStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops.map(threadStoreOperation => {
if (threadStoreOperation.type === 'replace') {
return {
diff --git a/lib/ops/user-store-ops.js b/lib/ops/user-store-ops.js
--- a/lib/ops/user-store-ops.js
+++ b/lib/ops/user-store-ops.js
@@ -87,8 +87,11 @@
},
convertOpsToClientDBOps(
- ops: $ReadOnlyArray<UserStoreOperation>,
+ ops: ?$ReadOnlyArray<UserStoreOperation>,
): $ReadOnlyArray<ClientDBUserStoreOperation> {
+ if (!ops) {
+ return [];
+ }
return ops.map(operation => {
if (
operation.type === 'remove_users' ||
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
@@ -63,7 +63,7 @@
syncedMetadataStoreOperations,
);
const keyserversToRemoveFromNotifsStore =
- getKeyserversToRemoveFromNotifsStore(keyserverStoreOperations);
+ getKeyserversToRemoveFromNotifsStore(keyserverStoreOperations ?? []);
const convertedIntegrityStoreOperations =
integrityStoreOpsHandlers.convertOpsToClientDBOps(integrityStoreOperations);
const convertedAuxUserStoreOperations =
@@ -96,7 +96,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
@@ -187,7 +187,7 @@
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
Tue, Nov 19, 6:27 PM (22 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2539893
Default Alt Text
D11936.id40154.diff (12 KB)

Event Timeline