Page MenuHomePhabricator

D13363.diff
No OneTemporary

D13363.diff

diff --git a/lib/reducers/dm-operations-queue-reducer.js b/lib/reducers/dm-operations-queue-reducer.js
--- a/lib/reducers/dm-operations-queue-reducer.js
+++ b/lib/reducers/dm-operations-queue-reducer.js
@@ -4,6 +4,7 @@
import {
clearQueuedThreadDMOpsActionType,
+ type OperationsQueue,
pruneDMOpsQueueActionType,
type QueuedDMOperations,
queueDMOpsActionType,
@@ -18,29 +19,40 @@
const { threadID, operation, timestamp } = action.payload;
return {
...store,
- operations: {
- ...store.operations,
+ threadQueue: {
+ ...store.threadQueue,
[threadID]: [
- ...(store.operations[threadID] ?? []),
+ ...(store.threadQueue[threadID] ?? []),
{ operation, timestamp },
],
},
};
} else if (action.type === pruneDMOpsQueueActionType) {
+ const filterOperations = (queue: OperationsQueue) =>
+ queue.filter(op => op.timestamp >= action.payload.pruneMaxTimestamp);
return {
...store,
- operations: _mapValues(operations =>
- operations.filter(
- op => op.timestamp >= action.payload.pruneMaxTimestamp,
+ threadQueue: _mapValues(operations => filterOperations(operations))(
+ store.threadQueue,
+ ),
+ messageQueue: _mapValues(operations => filterOperations(operations))(
+ store.messageQueue,
+ ),
+ entryQueue: _mapValues(operations => filterOperations(operations))(
+ store.entryQueue,
+ ),
+ membershipQueue: _mapValues(threadMembershipQueue =>
+ _mapValues(operations => filterOperations(operations))(
+ threadMembershipQueue,
),
- )(store.operations),
+ )(store.membershipQueue),
};
} else if (action.type === clearQueuedThreadDMOpsActionType) {
- const { [action.payload.threadID]: removed, ...operations } =
- store.operations;
+ const { [action.payload.threadID]: removed, ...threadQueue } =
+ store.threadQueue;
return {
...store,
- operations,
+ threadQueue,
};
}
return store;
diff --git a/lib/shared/dm-ops/dm-ops-queue-handler.react.js b/lib/shared/dm-ops/dm-ops-queue-handler.react.js
--- a/lib/shared/dm-ops/dm-ops-queue-handler.react.js
+++ b/lib/shared/dm-ops/dm-ops-queue-handler.react.js
@@ -46,7 +46,7 @@
const prevThreadIDsRef = React.useRef<$ReadOnlySet<string>>(new Set());
const queuedOperations = useSelector(
- state => state.queuedDMOperations.operations,
+ state => state.queuedDMOperations.threadQueue,
);
const processDMOperation = useProcessDMOperation();
diff --git a/lib/types/dm-ops.js b/lib/types/dm-ops.js
--- a/lib/types/dm-ops.js
+++ b/lib/types/dm-ops.js
@@ -521,11 +521,24 @@
+threadID: string,
};
+export type OperationsQueue = $ReadOnlyArray<{
+ +operation: DMOperation,
+ +timestamp: number,
+}>;
+
export type QueuedDMOperations = {
- +operations: {
- +[threadID: string]: $ReadOnlyArray<{
- +operation: DMOperation,
- +timestamp: number,
- }>,
+ +threadQueue: {
+ +[threadID: string]: OperationsQueue,
+ },
+ +messageQueue: {
+ +[messageID: string]: OperationsQueue,
+ },
+ +entryQueue: {
+ +[entryID: string]: OperationsQueue,
+ },
+ +membershipQueue: {
+ +[threadID: string]: {
+ +[memberID: string]: OperationsQueue,
+ },
},
};
diff --git a/lib/utils/reducers-utils.test.js b/lib/utils/reducers-utils.test.js
--- a/lib/utils/reducers-utils.test.js
+++ b/lib/utils/reducers-utils.test.js
@@ -99,7 +99,10 @@
tunnelbrokerToken: null,
},
queuedDMOperations: {
- operations: {},
+ threadQueue: {},
+ messageQueue: {},
+ entryQueue: {},
+ membershipQueue: {},
},
};
state = {
diff --git a/native/redux/default-state.js b/native/redux/default-state.js
--- a/native/redux/default-state.js
+++ b/native/redux/default-state.js
@@ -99,7 +99,10 @@
tunnelbrokerToken: null,
},
queuedDMOperations: {
- operations: {},
+ threadQueue: {},
+ messageQueue: {},
+ entryQueue: {},
+ membershipQueue: {},
},
}: AppState);
diff --git a/native/redux/persist.js b/native/redux/persist.js
--- a/native/redux/persist.js
+++ b/native/redux/persist.js
@@ -1463,6 +1463,18 @@
},
ops: [],
}),
+ [82]: (state: any) => ({
+ state: {
+ ...state,
+ queuedDMOperations: {
+ threadQueue: state.queuedDMOperations.operations,
+ messageQueue: {},
+ entryQueue: {},
+ membershipQueue: {},
+ },
+ },
+ ops: [],
+ }),
};
// NOTE: renaming this object, and especially the `version` property
@@ -1473,7 +1485,7 @@
storage: AsyncStorage,
blacklist: persistBlacklist,
debug: __DEV__,
- version: 81,
+ version: 82,
transforms: [
messageStoreMessagesBlocklistTransform,
reportStoreTransform,
diff --git a/web/redux/default-state.js b/web/redux/default-state.js
--- a/web/redux/default-state.js
+++ b/web/redux/default-state.js
@@ -95,7 +95,10 @@
tunnelbrokerToken: null,
},
queuedDMOperations: {
- operations: {},
+ threadQueue: {},
+ messageQueue: {},
+ entryQueue: {},
+ membershipQueue: {},
},
});
diff --git a/web/redux/persist-constants.js b/web/redux/persist-constants.js
--- a/web/redux/persist-constants.js
+++ b/web/redux/persist-constants.js
@@ -3,6 +3,6 @@
const rootKey = 'root';
const rootKeyPrefix = 'persist:';
const completeRootKey = `${rootKeyPrefix}${rootKey}`;
-const storeVersion = 81;
+const storeVersion = 82;
export { rootKey, rootKeyPrefix, completeRootKey, storeVersion };
diff --git a/web/redux/persist.js b/web/redux/persist.js
--- a/web/redux/persist.js
+++ b/web/redux/persist.js
@@ -620,6 +620,18 @@
},
ops: [],
}),
+ [82]: (state: any) => ({
+ state: {
+ ...state,
+ queuedDMOperations: {
+ threadQueue: state.queuedDMOperations.operations,
+ messageQueue: {},
+ entryQueue: {},
+ membershipQueue: {},
+ },
+ },
+ ops: [],
+ }),
};
const persistConfig: PersistConfig = {

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 27, 9:56 AM (17 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2590088
Default Alt Text
D13363.diff (5 KB)

Event Timeline