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 @@ -195,6 +195,33 @@ .flat(); } +function discardKeyserverUsernames( + newUserInfos: UserInfos, + stateUserInfos: UserInfos, +): UserInfos { + let result: UserInfos = {}; + for (const id in newUserInfos) { + if (stateUserInfos[id]) { + result = { + ...result, + [id]: { + ...newUserInfos[id], + username: stateUserInfos[id].username, + }, + }; + } else { + result = { + ...result, + [id]: { + ...newUserInfos[id], + username: null, + }, + }; + } + } + return result; +} + function reduceUserInfos( state: UserStore, action: BaseAction, @@ -248,10 +275,15 @@ if (keyserverID !== authoritativeKeyserverID()) { return [state, [], []]; } - const newUserInfos: UserInfos = _keyBy(userInfo => userInfo.id)( + const keyserverUserInfos: UserInfos = _keyBy(userInfo => userInfo.id)( action.payload.userInfos, ); + const newUserInfos = discardKeyserverUsernames( + keyserverUserInfos, + state.userInfos, + ); + const userStoreOps: $ReadOnlyArray = convertUserInfosToReplaceUserOps(newUserInfos); const processedUserInfos: UserInfos = processUserStoreOps(