Update members count from full chat info

This commit is contained in:
Alexander Zinchuk 2022-03-19 21:19:35 +01:00
parent 897c2f69ef
commit 2b55037b08
2 changed files with 12 additions and 2 deletions

View File

@ -339,6 +339,7 @@ async function getFullChatInfo(chatId: string): Promise<{
fullInfo: ApiChatFullInfo;
users?: ApiUser[];
groupCall?: Partial<ApiGroupCall>;
membersCount?: number;
} | undefined> {
const result = await invokeRequest(new GramJs.messages.GetFullChat({
chatId: buildInputEntity(chatId) as BigInt.BigInteger,
@ -391,6 +392,7 @@ async function getFullChatInfo(chatId: string): Promise<{
version: 0,
participants: {},
} : undefined,
membersCount: members?.length,
};
}
@ -402,6 +404,7 @@ async function getFullChannelInfo(
fullInfo: ApiChatFullInfo;
users?: ApiUser[];
groupCall?: Partial<ApiGroupCall>;
membersCount?: number;
} | undefined> {
const result = await invokeRequest(new GramJs.channels.GetFullChannel({
channel: buildInputEntity(id, accessHash) as GramJs.InputChannel,
@ -430,6 +433,7 @@ async function getFullChannelInfo(
requestsPending,
recentRequesters,
statsDc,
participantsCount,
} = result.fullChat;
const inviteLink = exportedInvite instanceof GramJs.ChatInviteExported
@ -498,6 +502,7 @@ async function getFullChannelInfo(
participantsCount: 0,
connectionState: 'disconnected',
} : undefined,
membersCount: participantsCount,
};
}

View File

@ -1079,7 +1079,9 @@ export async function loadFullChat(chat: ApiChat) {
return undefined;
}
const { users, fullInfo, groupCall } = result;
const {
users, fullInfo, groupCall, membersCount,
} = result;
let global = getGlobal();
if (users) {
@ -1097,7 +1099,10 @@ export async function loadFullChat(chat: ApiChat) {
);
}
global = updateChat(global, chat.id, { fullInfo });
global = updateChat(global, chat.id, {
fullInfo,
...(membersCount && { membersCount }),
});
setGlobal(global);