Page MenuHomePhabricator

D10274.id34453.diff
No OneTemporary

D10274.id34453.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
@@ -42,8 +42,8 @@
incrementalStateSyncActionType,
} from '../types/socket-types.js';
import type {
- LegacyRawThreadInfo,
- LegacyRawThreadInfos,
+ RawThreadInfo,
+ RawThreadInfos,
ThreadStore,
} from '../types/thread-types.js';
import {
@@ -56,7 +56,7 @@
threadStoreOpsHandlers;
function generateOpsForThreadUpdates(
- threadInfos: LegacyRawThreadInfos,
+ threadInfos: RawThreadInfos,
payload: {
+updatesResult: { +newUpdates: $ReadOnlyArray<ClientUpdateInfo>, ... },
...
@@ -169,31 +169,61 @@
};
} else if (action.type === updateSubscriptionActionTypes.success) {
const { threadID, subscription } = action.payload;
- const newThreadInfo = {
- ...state.threadInfos[threadID],
- currentUser: {
- ...state.threadInfos[threadID].currentUser,
- subscription,
- },
- };
- const threadStoreOperations = [
- {
- type: 'replace',
- payload: {
- id: threadID,
- threadInfo: newThreadInfo,
+ const threadInfo = state.threadInfos[threadID];
+ // TODO (atul): Try to get rid of this ridiculous branching.
+ if (threadInfo.minimallyEncoded) {
+ const newThreadInfo = {
+ ...threadInfo,
+ currentUser: {
+ ...threadInfo.currentUser,
+ subscription,
},
- },
- ];
- const updatedThreadStore = processThreadStoreOperations(
- state,
- threadStoreOperations,
- );
- return {
- threadStore: updatedThreadStore,
- newThreadInconsistencies: [],
- threadStoreOperations,
- };
+ };
+ const threadStoreOperations = [
+ {
+ type: 'replace',
+ payload: {
+ id: threadID,
+ threadInfo: newThreadInfo,
+ },
+ },
+ ];
+ const updatedThreadStore = processThreadStoreOperations(
+ state,
+ threadStoreOperations,
+ );
+ return {
+ threadStore: updatedThreadStore,
+ newThreadInconsistencies: [],
+ threadStoreOperations,
+ };
+ } else {
+ const newThreadInfo = {
+ ...threadInfo,
+ currentUser: {
+ ...threadInfo.currentUser,
+ subscription,
+ },
+ };
+ const threadStoreOperations = [
+ {
+ type: 'replace',
+ payload: {
+ id: threadID,
+ threadInfo: newThreadInfo,
+ },
+ },
+ ];
+ const updatedThreadStore = processThreadStoreOperations(
+ state,
+ threadStoreOperations,
+ );
+ return {
+ threadStore: updatedThreadStore,
+ newThreadInconsistencies: [],
+ threadStoreOperations,
+ };
+ }
} else if (action.type === saveMessagesActionType) {
const threadIDToMostRecentTime = new Map<string, number>();
for (const messageInfo of action.payload.rawMessageInfos) {
@@ -202,7 +232,7 @@
threadIDToMostRecentTime.set(messageInfo.threadID, messageInfo.time);
}
}
- const changedThreadInfos: { [string]: LegacyRawThreadInfo } = {};
+ const changedThreadInfos: { [string]: RawThreadInfo } = {};
for (const [threadID, mostRecentTime] of threadIDToMostRecentTime) {
const threadInfo = state.threadInfos[threadID];
if (
@@ -212,13 +242,25 @@
) {
continue;
}
- changedThreadInfos[threadID] = {
- ...state.threadInfos[threadID],
- currentUser: {
- ...state.threadInfos[threadID].currentUser,
- unread: true,
- },
- };
+ const changedThreadInfo = state.threadInfos[threadID];
+ // TODO (atul): Try to get rid of this ridiculous branching.
+ if (changedThreadInfo.minimallyEncoded) {
+ changedThreadInfos[threadID] = {
+ ...changedThreadInfo,
+ currentUser: {
+ ...changedThreadInfo.currentUser,
+ unread: true,
+ },
+ };
+ } else {
+ changedThreadInfos[threadID] = {
+ ...changedThreadInfo,
+ currentUser: {
+ ...changedThreadInfo.currentUser,
+ unread: true,
+ },
+ };
+ }
}
if (Object.keys(changedThreadInfos).length !== 0) {
const threadStoreOperations = Object.keys(changedThreadInfos).map(id => ({
@@ -297,19 +339,33 @@
threadStoreOperations,
};
} else if (action.type === updateActivityActionTypes.success) {
- const updatedThreadInfos: { [string]: LegacyRawThreadInfo } = {};
+ const updatedThreadInfos: { [string]: RawThreadInfo } = {};
for (const setToUnread of action.payload.result.unfocusedToUnread) {
const threadInfo = state.threadInfos[setToUnread];
- if (threadInfo && !threadInfo.currentUser.unread) {
- updatedThreadInfos[setToUnread] = {
- ...threadInfo,
- currentUser: {
- ...threadInfo.currentUser,
- unread: true,
- },
- };
+ // TODO (atul): Try to get rid of this ridiculous branching.
+ if (threadInfo.minimallyEncoded) {
+ if (threadInfo && !threadInfo.currentUser.unread) {
+ updatedThreadInfos[setToUnread] = {
+ ...threadInfo,
+ currentUser: {
+ ...threadInfo.currentUser,
+ unread: true,
+ },
+ };
+ }
+ } else {
+ if (threadInfo && !threadInfo.currentUser.unread) {
+ updatedThreadInfos[setToUnread] = {
+ ...threadInfo,
+ currentUser: {
+ ...threadInfo.currentUser,
+ unread: true,
+ },
+ };
+ }
}
}
+
if (Object.keys(updatedThreadInfos).length === 0) {
return {
threadStore: state,
@@ -335,31 +391,61 @@
};
} else if (action.type === setThreadUnreadStatusActionTypes.started) {
const { threadID, unread } = action.payload;
- const updatedThreadInfo = {
- ...state.threadInfos[threadID],
- currentUser: {
- ...state.threadInfos[threadID].currentUser,
- unread,
- },
- };
- const threadStoreOperations = [
- {
- type: 'replace',
- payload: {
- id: threadID,
- threadInfo: updatedThreadInfo,
+ 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 updatedThreadStore = processThreadStoreOperations(
- state,
- threadStoreOperations,
- );
- return {
- threadStore: updatedThreadStore,
- newThreadInconsistencies: [],
- threadStoreOperations,
- };
+ };
+ const threadStoreOperations = [
+ {
+ type: 'replace',
+ payload: {
+ id: threadID,
+ threadInfo: updatedThreadInfo,
+ },
+ },
+ ];
+ 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,
+ },
+ },
+ ];
+ 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;
@@ -372,32 +458,55 @@
};
}
- const updatedUser = {
- ...currentUser,
- unread: true,
- };
- const updatedThread = {
- ...state.threadInfos[threadID],
- currentUser: updatedUser,
- };
- const threadStoreOperations = [
- {
- type: 'replace',
- payload: {
- id: threadID,
- threadInfo: updatedThread,
+ const threadInfo = state.threadInfos[threadID];
+ // TODO (atul): Try to get rid of this ridiculous branching.
+ if (threadInfo.minimallyEncoded) {
+ const updatedThread = {
+ ...threadInfo,
+ currentUser: { ...threadInfo.currentUser, unread: true },
+ };
+ const threadStoreOperations = [
+ {
+ type: 'replace',
+ payload: {
+ id: threadID,
+ threadInfo: updatedThread,
+ },
},
- },
- ];
- const updatedThreadStore = processThreadStoreOperations(
- state,
- threadStoreOperations,
- );
- return {
- threadStore: updatedThreadStore,
- newThreadInconsistencies: [],
- threadStoreOperations,
- };
+ ];
+ const updatedThreadStore = processThreadStoreOperations(
+ state,
+ threadStoreOperations,
+ );
+ return {
+ threadStore: updatedThreadStore,
+ newThreadInconsistencies: [],
+ threadStoreOperations,
+ };
+ } else {
+ const updatedThread = {
+ ...threadInfo,
+ currentUser: { ...threadInfo.currentUser, unread: true },
+ };
+ const threadStoreOperations = [
+ {
+ type: 'replace',
+ payload: {
+ id: threadID,
+ threadInfo: updatedThread,
+ },
+ },
+ ];
+ const updatedThreadStore = processThreadStoreOperations(
+ state,
+ threadStoreOperations,
+ );
+ return {
+ threadStore: updatedThreadStore,
+ newThreadInconsistencies: [],
+ threadStoreOperations,
+ };
+ }
} else if (action.type === setClientDBStoreActionType) {
return {
threadStore: action.payload.threadStore ?? state,

File Metadata

Mime Type
text/plain
Expires
Wed, Nov 6, 9:45 PM (19 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2432674
Default Alt Text
D10274.id34453.diff (10 KB)

Event Timeline