Page MenuHomePhabricator

D12957.diff
No OneTemporary

D12957.diff

diff --git a/lib/reducers/thread-reducer.js b/lib/reducers/thread-reducer.js
--- a/lib/reducers/thread-reducer.js
+++ b/lib/reducers/thread-reducer.js
@@ -59,19 +59,28 @@
const { processStoreOperations: processThreadStoreOperations } =
threadStoreOpsHandlers;
-function generateOpsForThreadUpdates(
- threadInfos: RawThreadInfos,
+function generateOpsAndProcessThreadUpdates(
+ threadStore: ThreadStore,
newUpdates: $ReadOnlyArray<ClientUpdateInfo>,
-): $ReadOnlyArray<ThreadStoreOperation> {
- return newUpdates
- .map(update =>
- updateSpecs[update.type].generateOpsForThreadUpdates?.(
- threadInfos,
- update,
- ),
- )
- .filter(Boolean)
- .flat();
+): {
+ +threadStoreOperations: $ReadOnlyArray<ThreadStoreOperation>,
+ +updatedThreadStore: ThreadStore,
+} {
+ const operations: Array<ThreadStoreOperation> = [];
+ let store = threadStore;
+ for (const update of newUpdates) {
+ const ops = updateSpecs[update.type].generateOpsForThreadUpdates?.(
+ store.threadInfos,
+ update,
+ );
+ if (!ops || ops.length === 0) {
+ continue;
+ }
+
+ operations.push(...ops);
+ store = processThreadStoreOperations(store, ops);
+ }
+ return { threadStoreOperations: operations, updatedThreadStore: store };
}
type ReduceThreadInfosResult = {
@@ -261,14 +270,8 @@
threadStoreOperations: [],
};
}
- const threadStoreOperations = generateOpsForThreadUpdates(
- state.threadInfos,
- newUpdates,
- );
- const updatedThreadStore = processThreadStoreOperations(
- state,
- threadStoreOperations,
- );
+ const { threadStoreOperations, updatedThreadStore } =
+ generateOpsAndProcessThreadUpdates(state, newUpdates);
return {
threadStore: updatedThreadStore,
newThreadInconsistencies: [],
@@ -286,14 +289,8 @@
threadStoreOperations: [],
};
}
- const threadStoreOperations = generateOpsForThreadUpdates(
- state.threadInfos,
- newUpdates,
- );
- const updatedThreadStore = processThreadStoreOperations(
- state,
- threadStoreOperations,
- );
+ const { threadStoreOperations, updatedThreadStore } =
+ generateOpsAndProcessThreadUpdates(state, newUpdates);
return {
threadStore: updatedThreadStore,
newThreadInconsistencies: [],
@@ -544,14 +541,8 @@
threadStoreOperations: [],
};
}
- const threadStoreOperations = generateOpsForThreadUpdates(
- state.threadInfos,
- updateInfos,
- );
- const updatedThreadStore = processThreadStoreOperations(
- state,
- threadStoreOperations,
- );
+ const { threadStoreOperations, updatedThreadStore } =
+ generateOpsAndProcessThreadUpdates(state, updateInfos);
return {
threadStore: updatedThreadStore,
newThreadInconsistencies: [],

File Metadata

Mime Type
text/plain
Expires
Tue, Nov 26, 2:58 PM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2585250
Default Alt Text
D12957.diff (2 KB)

Event Timeline