Settings: Fix selecting main profile photo (#2887)
This commit is contained in:
parent
fbdeb9fd40
commit
2e9dcb8060
@ -106,7 +106,7 @@ addActionHandler('updateProfilePhoto', async (global, actions, payload): Promise
|
|||||||
const { photo, isFallback } = payload;
|
const { photo, isFallback } = payload;
|
||||||
const { currentUserId } = global;
|
const { currentUserId } = global;
|
||||||
if (!currentUserId) return;
|
if (!currentUserId) return;
|
||||||
const currentUser = selectChat(global, currentUserId);
|
const currentUser = selectUser(global, currentUserId);
|
||||||
if (!currentUser) return;
|
if (!currentUser) return;
|
||||||
|
|
||||||
global = updateUser(global, currentUserId, {
|
global = updateUser(global, currentUserId, {
|
||||||
@ -121,17 +121,9 @@ addActionHandler('updateProfilePhoto', async (global, actions, payload): Promise
|
|||||||
const result = await callApi('updateProfilePhoto', photo, isFallback);
|
const result = await callApi('updateProfilePhoto', photo, isFallback);
|
||||||
if (!result) return;
|
if (!result) return;
|
||||||
|
|
||||||
const { photo: newPhoto, users } = result;
|
const { users } = result;
|
||||||
global = getGlobal();
|
global = getGlobal();
|
||||||
global = addUsers(global, buildCollectionByKey(users, 'id'));
|
global = addUsers(global, buildCollectionByKey(users, 'id'));
|
||||||
|
|
||||||
global = updateUser(global, currentUserId, {
|
|
||||||
avatarHash: newPhoto.id,
|
|
||||||
fullInfo: {
|
|
||||||
...currentUser.fullInfo,
|
|
||||||
profilePhoto: newPhoto,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
setGlobal(global);
|
setGlobal(global);
|
||||||
|
|
||||||
actions.loadFullUser({ userId: currentUserId });
|
actions.loadFullUser({ userId: currentUserId });
|
||||||
|
|||||||
@ -246,7 +246,7 @@ addActionHandler('loadProfilePhotos', async (global, actions, payload): Promise<
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user && !user?.fullInfo) {
|
if (user && !user.fullInfo?.profilePhoto) {
|
||||||
const { id, accessHash } = user;
|
const { id, accessHash } = user;
|
||||||
user = await callApi('fetchFullUser', { id, accessHash });
|
user = await callApi('fetchFullUser', { id, accessHash });
|
||||||
if (!user) return;
|
if (!user) return;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user