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 @@ -10,6 +10,7 @@ newThreadActionTypes, } from '../actions/thread-actions.js'; import { + keyserverAuthActionTypes, logOutActionTypes, deleteKeyserverAccountActionTypes, logInActionTypes, @@ -46,6 +47,7 @@ } from '../types/user-types.js'; import { getMessageForException } from '../utils/errors.js'; import { assertObjectsAreEqual } from '../utils/objects.js'; +import { usingCommServicesAccessToken } from '../utils/services-utils.js'; function reduceCurrentUserInfo( state: ?CurrentUserInfo, @@ -215,6 +217,9 @@ (action.type === setNewSessionActionType && action.payload.sessionChange.cookieInvalidated) ) { + if (usingCommServicesAccessToken) { + return [state, [], []]; + } const userStoreOps: $ReadOnlyArray = [ { type: 'remove_all_users' }, ]; @@ -276,6 +281,36 @@ userStoreOps, ]; } + } else if (action.type === keyserverAuthActionTypes.success) { + const newUserInfos = _keyBy(userInfo => userInfo.id)( + action.payload.userInfos, + ); + const mergedUserInfos: UserInfos = { ...state.userInfos, ...newUserInfos }; + + const userStoreOps: $ReadOnlyArray = [ + ...convertUserInfosToReplaceUserOps(newUserInfos), + ]; + const processedUserInfos: UserInfos = processUserStoreOps( + state.userInfos, + userStoreOps, + ); + assertUserStoresAreEqual( + processedUserInfos, + mergedUserInfos, + action.type, + onStateDifference, + ); + + if (!_isEqual(state.userInfos)(mergedUserInfos)) { + return [ + { + ...state, + userInfos: mergedUserInfos, + }, + [], + userStoreOps, + ]; + } } else if ( action.type === incrementalStateSyncActionType || action.type === processUpdatesActionType