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 @@ -372,60 +372,40 @@ } else if (action.type === setThreadUnreadStatusActionTypes.started) { const { threadID, unread } = action.payload; const threadInfo = state.threadInfos[threadID]; - // TODO (atul): Try to get rid of this ridiculous branching. - if (threadInfo.minimallyEncoded) { - const updatedThreadInfo = { - ...threadInfo, - currentUser: { - ...threadInfo.currentUser, - unread, - }, - }; - const threadStoreOperations = [ - { - type: 'replace', - payload: { - id: threadID, - threadInfo: updatedThreadInfo, + const updatedThreadInfo = threadInfo.minimallyEncoded + ? { + ...threadInfo, + currentUser: { + ...threadInfo.currentUser, + unread, }, - }, - ]; - const updatedThreadStore = processThreadStoreOperations( - state, - threadStoreOperations, - ); - return { - threadStore: updatedThreadStore, - newThreadInconsistencies: [], - threadStoreOperations, - }; - } else { - const updatedThreadInfo = { - ...threadInfo, - currentUser: { - ...threadInfo.currentUser, - unread, - }, - }; - const threadStoreOperations = [ - { - type: 'replace', - payload: { - id: threadID, - threadInfo: updatedThreadInfo, + } + : { + ...threadInfo, + currentUser: { + ...threadInfo.currentUser, + unread, }, + }; + + const threadStoreOperations = [ + { + type: 'replace', + payload: { + id: threadID, + threadInfo: updatedThreadInfo, }, - ]; - const updatedThreadStore = processThreadStoreOperations( - state, - threadStoreOperations, - ); - return { - threadStore: updatedThreadStore, - newThreadInconsistencies: [], - threadStoreOperations, - }; - } + }, + ]; + const updatedThreadStore = processThreadStoreOperations( + state, + threadStoreOperations, + ); + return { + threadStore: updatedThreadStore, + newThreadInconsistencies: [], + threadStoreOperations, + }; } else if (action.type === setThreadUnreadStatusActionTypes.success) { const { threadID, resetToUnread } = action.payload; const currentUser = state.threadInfos[threadID].currentUser;