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;