From 2e9dcb8060fe13e960d58886061bc8265a47bc26 Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Thu, 30 Mar 2023 18:25:49 -0500 Subject: [PATCH] Settings: Fix selecting main profile photo (#2887) --- src/global/actions/api/settings.ts | 12 ++---------- src/global/actions/api/users.ts | 2 +- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/global/actions/api/settings.ts b/src/global/actions/api/settings.ts index 49ca7b07b..041f31f64 100644 --- a/src/global/actions/api/settings.ts +++ b/src/global/actions/api/settings.ts @@ -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 }); diff --git a/src/global/actions/api/users.ts b/src/global/actions/api/users.ts index 8dddad94a..60878f1a0 100644 --- a/src/global/actions/api/users.ts +++ b/src/global/actions/api/users.ts @@ -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;