Settings: Fix selecting main profile photo (#2887)

This commit is contained in:
Alexander Zinchuk 2023-03-30 18:25:49 -05:00
parent fbdeb9fd40
commit 2e9dcb8060
2 changed files with 3 additions and 11 deletions

View File

@ -106,7 +106,7 @@ addActionHandler('updateProfilePhoto', async (global, actions, payload): Promise
const { photo, isFallback } = payload;
const { currentUserId } = global;
if (!currentUserId) return;
const currentUser = selectChat(global, currentUserId);
const currentUser = selectUser(global, currentUserId);
if (!currentUser) return;
global = updateUser(global, currentUserId, {
@ -121,17 +121,9 @@ addActionHandler('updateProfilePhoto', async (global, actions, payload): Promise
const result = await callApi('updateProfilePhoto', photo, isFallback);
if (!result) return;
const { photo: newPhoto, users } = result;
const { users } = result;
global = getGlobal();
global = addUsers(global, buildCollectionByKey(users, 'id'));
global = updateUser(global, currentUserId, {
avatarHash: newPhoto.id,
fullInfo: {
...currentUser.fullInfo,
profilePhoto: newPhoto,
},
});
setGlobal(global);
actions.loadFullUser({ userId: currentUserId });

View File

@ -246,7 +246,7 @@ addActionHandler('loadProfilePhotos', async (global, actions, payload): Promise<
return;
}
if (user && !user?.fullInfo) {
if (user && !user.fullInfo?.profilePhoto) {
const { id, accessHash } = user;
user = await callApi('fetchFullUser', { id, accessHash });
if (!user) return;