Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3356296
D4197.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
D4197.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
@@ -58,12 +58,7 @@
+updatesResult: { +newUpdates: $ReadOnlyArray<ClientUpdateInfo>, ... },
...
},
-): {
- +threadStoreOperations: $ReadOnlyArray<ThreadStoreOperation>,
- +threadInfos: { +[id: string]: RawThreadInfo },
-} {
- const updatedThreadInfos = { ...threadInfos };
- let someThreadUpdated = false;
+): $ReadOnlyArray<ThreadStoreOperation> {
const threadOperations: ThreadStoreOperation[] = [];
for (const update of payload.updatesResult.newUpdates) {
if (
@@ -71,8 +66,6 @@
update.type === updateTypes.JOIN_THREAD) &&
!_isEqual(threadInfos[update.threadInfo.id])(update.threadInfo)
) {
- someThreadUpdated = true;
- updatedThreadInfos[update.threadInfo.id] = update.threadInfo;
threadOperations.push({
type: 'replace',
payload: {
@@ -85,7 +78,6 @@
threadInfos[update.threadID] &&
threadInfos[update.threadID].currentUser.unread !== update.unread
) {
- someThreadUpdated = true;
const updatedThread = {
...threadInfos[update.threadID],
currentUser: {
@@ -93,7 +85,6 @@
unread: update.unread,
},
};
- updatedThreadInfos[update.threadID] = updatedThread;
threadOperations.push({
type: 'replace',
payload: {
@@ -105,8 +96,6 @@
update.type === updateTypes.DELETE_THREAD &&
threadInfos[update.threadID]
) {
- someThreadUpdated = true;
- delete updatedThreadInfos[update.threadID];
threadOperations.push({
type: 'remove',
payload: {
@@ -120,12 +109,10 @@
member => member.id !== update.deletedUserID,
);
if (newMembers.length < threadInfo.members.length) {
- someThreadUpdated = true;
const updatedThread = {
...threadInfo,
members: newMembers,
};
- updatedThreadInfos[threadID] = updatedThread;
threadOperations.push({
type: 'replace',
payload: {
@@ -137,13 +124,7 @@
}
}
}
- if (!someThreadUpdated) {
- return { threadStoreOperations: [], threadInfos };
- }
- return {
- threadStoreOperations: threadOperations,
- threadInfos: updatedThreadInfos,
- };
+ return threadOperations;
}
const emptyArray = [];
@@ -245,7 +226,7 @@
threadStoreOperations: [],
};
}
- const { threadStoreOperations } = reduceThreadUpdates(
+ const threadStoreOperations = reduceThreadUpdates(
state.threadInfos,
action.payload,
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 6:03 PM (19 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2576923
Default Alt Text
D4197.diff (2 KB)
Attached To
Mode
D4197: [lib] Exclusively use "ops approach" in `reduceThreadUpdates`
Attached
Detach File
Event Timeline
Log In to Comment