Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3367517
D12957.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D12957.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D12957: [lib] Correctly handle generating ops from multiple updates
Attached
Detach File
Event Timeline
Log In to Comment