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,8 @@ newThreadActionTypes, } from '../actions/thread-actions.js'; import { + identityLogInActionTypes, + identityRegisterActionTypes, deleteAccountActionTypes, keyserverAuthActionTypes, logOutActionTypes, @@ -55,6 +57,35 @@ action: BaseAction, ): ?CurrentUserInfo { if ( + action.type === identityLogInActionTypes.success || + action.type === identityRegisterActionTypes.success + ) { + const newUserInfo = { + id: action.payload.userID, + username: action.payload.username, + }; + if (!_isEqual(newUserInfo)(state)) { + return newUserInfo; + } + } else if (action.type === keyserverAuthActionTypes.success) { + const { currentUserInfo: actionUserInfo } = action.payload; + if (actionUserInfo) { + if (!state?.id || actionUserInfo.id !== state.id) { + console.log( + 'keyserver auth returned a different user info than identity login', + ); + } else { + const newUserInfo = { + ...state, + avatar: actionUserInfo.avatar, + settings: actionUserInfo.settings, + }; + if (!_isEqual(newUserInfo)(state)) { + return newUserInfo; + } + } + } + } else if ( action.type === logInActionTypes.success || action.type === siweAuthActionTypes.success || action.type === keyserverRegisterActionTypes.success ||