Chat Management: Changing the group type (#3136)
This commit is contained in:
parent
4406831e02
commit
287dfe640a
@ -51,14 +51,17 @@ export async function setChatUsername(
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const usernames = chat.usernames
|
const usernames = chat.usernames
|
||||||
? chat.usernames.map((u) => (u.isEditable ? { ...u, username } : u))
|
? chat.usernames
|
||||||
|
.map((u) => (u.isEditable ? { ...u, username } : u))
|
||||||
|
// User can remove username from chat when changing it type to private, so we need to filter out empty usernames
|
||||||
|
.filter((u) => u.username)
|
||||||
: [{ username, isEditable: true, isActive: true }];
|
: [{ username, isEditable: true, isActive: true }];
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
onUpdate({
|
onUpdate({
|
||||||
'@type': 'updateChat',
|
'@type': 'updateChat',
|
||||||
id: chat.id,
|
id: chat.id,
|
||||||
chat: { usernames },
|
chat: { usernames: usernames.length ? usernames : undefined },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -31,5 +31,6 @@ export function areDeepEqual<T extends any>(value1: T, value2: T): boolean {
|
|||||||
const object2 = value2 as AnyLiteral;
|
const object2 = value2 as AnyLiteral;
|
||||||
const keys1 = Object.keys(object1);
|
const keys1 = Object.keys(object1);
|
||||||
|
|
||||||
return keys1.every((key1) => areDeepEqual(object1[key1], object2[key1]));
|
return keys1.length === Object.keys(object2).length
|
||||||
|
&& keys1.every((key1) => areDeepEqual(object1[key1], object2[key1]));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user