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, ... }, ... }, -): { - +threadStoreOperations: $ReadOnlyArray, - +threadInfos: { +[id: string]: RawThreadInfo }, -} { - const updatedThreadInfos = { ...threadInfos }; - let someThreadUpdated = false; +): $ReadOnlyArray { 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, );