diff --git a/src/api/gramjs/methods/chats.ts b/src/api/gramjs/methods/chats.ts index 8489c19e9..9ac1e2833 100644 --- a/src/api/gramjs/methods/chats.ts +++ b/src/api/gramjs/methods/chats.ts @@ -1564,42 +1564,12 @@ export async function addChatMembers(chat: ApiChat, users: ApiUser[]) { } export function deleteChatMember(chat: ApiChat, user: ApiUser) { - if (chat.type === 'chatTypeChannel' || chat.type === 'chatTypeSuperGroup') { - return updateChatMemberBannedRights({ - chat, - user, - bannedRights: { - viewMessages: true, - sendMessages: true, - sendMedia: true, - sendStickers: true, - sendGifs: true, - sendGames: true, - sendInline: true, - embedLinks: true, - sendPolls: true, - changeInfo: true, - inviteUsers: true, - pinMessages: true, - manageTopics: true, - sendPhotos: true, - sendVideos: true, - sendRoundvideos: true, - sendAudios: true, - sendVoices: true, - sendDocs: true, - sendPlain: true, - }, - untilDate: MAX_INT_32, - }); - } else { - return invokeRequest(new GramJs.messages.DeleteChatUser({ - chatId: buildInputChat(chat.id), - userId: buildInputUser(user.id, user.accessHash), - }), { - shouldReturnTrue: true, - }); - } + return invokeRequest(new GramJs.messages.DeleteChatUser({ + chatId: buildInputChat(chat.id), + userId: buildInputUser(user.id, user.accessHash), + }), { + shouldReturnTrue: true, + }); } export function toggleJoinToSend(chat: ApiChat, isEnabled: boolean) { diff --git a/src/global/actions/api/chats.ts b/src/global/actions/api/chats.ts index 3f11cd15b..8ca750240 100644 --- a/src/global/actions/api/chats.ts +++ b/src/global/actions/api/chats.ts @@ -1857,7 +1857,11 @@ addActionHandler('updateChatMemberBannedRights', async (global, actions, payload if (!chat) return; - await callApi('updateChatMemberBannedRights', { chat, user, bannedRights }); + const result = await callApi('updateChatMemberBannedRights', { chat, user, bannedRights }); + + if (!result) { + return; + } global = getGlobal(); @@ -1886,6 +1890,10 @@ addActionHandler('updateChatMemberBannedRights', async (global, actions, payload kickedMembers: kickedMembers.filter((m) => m.userId !== userId), }), }); + if (isBanned) { + global = updateChat(global, chat.id, { membersCount: Math.max(0, (chat.membersCount || 0) - 1) }); + } + setGlobal(global); }); @@ -2181,7 +2189,7 @@ addActionHandler('addChatMembers', async (global, actions, payload): Promise => { - const { chatId, userId } = payload; + const { chatId, userId, tabId = getCurrentTabId() } = payload; const chat = selectChat(global, chatId); const user = selectUser(global, userId); @@ -2189,6 +2197,37 @@ addActionHandler('deleteChatMember', async (global, actions, payload): Promise