Page MenuHomePhabricator

D9908.diff
No OneTemporary

D9908.diff

diff --git a/lib/reducers/master-reducer.js b/lib/reducers/master-reducer.js
--- a/lib/reducers/master-reducer.js
+++ b/lib/reducers/master-reducer.js
@@ -62,11 +62,8 @@
}
};
- const [userStore, newUserInconsistencies] = reduceUserInfos(
- state.userStore,
- action,
- onStateDifferenceForStaff,
- );
+ const [userStore, newUserInconsistencies, userStoreOperations] =
+ reduceUserInfos(state.userStore, action, onStateDifferenceForStaff);
const newInconsistencies = [
...newEntryInconsistencies,
@@ -182,6 +179,7 @@
threadStoreOperations,
messageStoreOperations,
reportStoreOperations,
+ userStoreOperations,
},
};
}
diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js
--- a/lib/reducers/user-reducer.js
+++ b/lib/reducers/user-reducer.js
@@ -175,7 +175,11 @@
state: UserStore,
action: BaseAction,
onStateDifference: (message: string) => mixed,
-): [UserStore, $ReadOnlyArray<ClientUserInconsistencyReportCreationRequest>] {
+): [
+ UserStore,
+ $ReadOnlyArray<ClientUserInconsistencyReportCreationRequest>,
+ $ReadOnlyArray<UserStoreOperation>,
+] {
if (
action.type === joinThreadActionTypes.success ||
action.type === newThreadActionTypes.success
@@ -184,9 +188,11 @@
action.payload.userInfos,
);
+ const userStoreOps: $ReadOnlyArray<UserStoreOperation> =
+ convertUserInfosToReplaceUserOps(newUserInfos);
const processedUserInfos: UserInfos = processUserStoreOps(
state.userInfos,
- convertUserInfosToReplaceUserOps(newUserInfos),
+ userStoreOps,
);
const updated: UserInfos = { ...state.userInfos, ...newUserInfos };
assertUserStoresAreEqual(
@@ -203,6 +209,7 @@
userInfos: updated,
},
[],
+ userStoreOps,
];
}
} else if (
@@ -211,9 +218,13 @@
(action.type === setNewSessionActionType &&
action.payload.sessionChange.cookieInvalidated)
) {
- const processedUserInfos: UserInfos = processUserStoreOps(state.userInfos, [
+ const userStoreOps: $ReadOnlyArray<UserStoreOperation> = [
{ type: 'remove_all_users' },
- ]);
+ ];
+ const processedUserInfos: UserInfos = processUserStoreOps(
+ state.userInfos,
+ userStoreOps,
+ );
assertUserStoresAreEqual(
processedUserInfos,
{},
@@ -222,13 +233,14 @@
);
if (Object.keys(state.userInfos).length === 0) {
- return [state, []];
+ return [state, [], []];
}
return [
{
userInfos: {},
},
[],
+ userStoreOps,
];
} else if (
action.type === logInActionTypes.success ||
@@ -239,10 +251,14 @@
const newUserInfos = _keyBy(userInfo => userInfo.id)(
action.payload.userInfos,
);
- const processedUserInfos: UserInfos = processUserStoreOps(state.userInfos, [
+ const userStoreOps: $ReadOnlyArray<UserStoreOperation> = [
{ type: 'remove_all_users' },
...convertUserInfosToReplaceUserOps(newUserInfos),
- ]);
+ ];
+ const processedUserInfos: UserInfos = processUserStoreOps(
+ state.userInfos,
+ userStoreOps,
+ );
assertUserStoresAreEqual(
processedUserInfos,
newUserInfos,
@@ -255,6 +271,7 @@
userInfos: newUserInfos,
},
[],
+ userStoreOps,
];
}
} else if (
@@ -264,7 +281,7 @@
const newUserInfos = _keyBy(userInfo => userInfo.id)(
action.payload.userInfos,
);
- const userStoreOps: UserStoreOperation[] = [
+ const userStoreOps: $ReadOnlyArray<UserStoreOperation> = [
...convertUserInfosToReplaceUserOps(newUserInfos),
...generateOpsForUserUpdates(action.payload),
];
@@ -296,6 +313,7 @@
userInfos: updated,
},
[],
+ userStoreOps,
];
}
} else if (action.type === processServerRequestsActionType) {
@@ -303,11 +321,11 @@
candidate => candidate.type === serverRequestTypes.CHECK_STATE,
);
if (!checkStateRequest || !checkStateRequest.stateChanges) {
- return [state, []];
+ return [state, [], []];
}
const { userInfos, deleteUserInfoIDs } = checkStateRequest.stateChanges;
if (!userInfos && !deleteUserInfoIDs) {
- return [state, []];
+ return [state, [], []];
}
const userStoreOps: UserStoreOperation[] = [];
@@ -349,14 +367,17 @@
userInfos: newUserInfos,
},
newInconsistencies,
+ userStoreOps,
];
} else if (action.type === updateUserAvatarActionTypes.success) {
const newUserInfos = _keyBy(userInfo => userInfo.id)(
action.payload.updates.userInfos,
);
+ const userStoreOps: $ReadOnlyArray<UserStoreOperation> =
+ convertUserInfosToReplaceUserOps(newUserInfos);
const processedUserInfos: UserInfos = processUserStoreOps(
state.userInfos,
- convertUserInfosToReplaceUserOps(newUserInfos),
+ userStoreOps,
);
const updated: UserInfos = { ...state.userInfos, ...newUserInfos };
assertUserStoresAreEqual(
@@ -371,10 +392,10 @@
userInfos: updated,
}
: state;
- return [newState, []];
+ return [newState, [], userStoreOps];
}
- return [state, []];
+ return [state, [], []];
}
export { reduceCurrentUserInfo, reduceUserInfos };
diff --git a/lib/types/store-ops-types.js b/lib/types/store-ops-types.js
--- a/lib/types/store-ops-types.js
+++ b/lib/types/store-ops-types.js
@@ -23,12 +23,14 @@
ClientDBThreadStoreOperation,
ThreadStoreOperation,
} from '../ops/thread-store-ops.js';
+import type { UserStoreOperation } from '../ops/user-store-ops.js';
export type StoreOperations = {
+draftStoreOperations: $ReadOnlyArray<DraftStoreOperation>,
+threadStoreOperations: $ReadOnlyArray<ThreadStoreOperation>,
+messageStoreOperations: $ReadOnlyArray<MessageStoreOperation>,
+reportStoreOperations: $ReadOnlyArray<ReportStoreOperation>,
+ +userStoreOperations: $ReadOnlyArray<UserStoreOperation>,
};
export type ClientDBStoreOperations = {
diff --git a/native/redux/redux-setup.js b/native/redux/redux-setup.js
--- a/native/redux/redux-setup.js
+++ b/native/redux/redux-setup.js
@@ -234,6 +234,7 @@
threadStoreOperations,
messageStoreOperations,
reportStoreOperations,
+ userStoreOperations,
} = storeOperations;
const fixUnreadActiveThreadResult = fixUnreadActiveThread(state, action);
@@ -249,6 +250,7 @@
messageStoreOperations,
threadStoreOperations: threadStoreOperationsWithUnreadFix,
reportStoreOperations,
+ userStoreOperations,
});
return state;

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 6:22 AM (1 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2610572
Default Alt Text
D9908.diff (6 KB)

Event Timeline