diff --git a/src/api/gramjs/methods/messages.ts b/src/api/gramjs/methods/messages.ts index 01bfccdd..34dbbd43 100644 --- a/src/api/gramjs/methods/messages.ts +++ b/src/api/gramjs/methods/messages.ts @@ -676,7 +676,7 @@ export async function deleteScheduledMessages({ } export async function deleteHistory({ - chat, shouldDeleteForAll, maxId, + chat, shouldDeleteForAll, }: { chat: ApiChat; shouldDeleteForAll?: boolean; maxId?: number; }) { @@ -685,13 +685,11 @@ export async function deleteHistory({ isChannel ? new GramJs.channels.DeleteHistory({ channel: buildInputEntity(chat.id, chat.accessHash) as GramJs.InputChannel, - maxId, }) : new GramJs.messages.DeleteHistory({ peer: buildInputPeer(chat.id, chat.accessHash), ...(shouldDeleteForAll && { revoke: true }), ...(!shouldDeleteForAll && { just_clear: true }), - maxId, }), ); @@ -699,6 +697,11 @@ export async function deleteHistory({ return; } + if ('offset' in result && result.offset) { + await deleteHistory({ chat, shouldDeleteForAll }); + return; + } + onUpdate({ '@type': 'deleteHistory', chatId: chat.id, diff --git a/src/components/common/DeleteChatModal.tsx b/src/components/common/DeleteChatModal.tsx index a16eb852..6bc0a546 100644 --- a/src/components/common/DeleteChatModal.tsx +++ b/src/components/common/DeleteChatModal.tsx @@ -72,7 +72,7 @@ const DeleteChatModal: FC = ({ const lang = useLang(); const chatTitle = getChatTitle(lang, chat); - const handleDeleteMessageForAll = useCallback(() => { + const handleDeleteForAll = useCallback(() => { deleteHistory({ chatId: chat.id, shouldDeleteForAll: true }); onClose(); @@ -152,7 +152,7 @@ const DeleteChatModal: FC = ({ return 'DeleteChatUser'; } - function renderMessage() { + function renderContent() { if (isChannel && chat.isCreator) { return (

@@ -191,14 +191,14 @@ const DeleteChatModal: FC = ({ onClose={onClose} onCloseAnimationEnd={onCloseAnimationEnd} > - {renderMessage()} + {renderContent()} {isBot && ( )} {canDeleteForAll && ( - )} diff --git a/src/global/actions/api/messages.ts b/src/global/actions/api/messages.ts index 212475d4..868d646c 100644 --- a/src/global/actions/api/messages.ts +++ b/src/global/actions/api/messages.ts @@ -449,9 +449,7 @@ addActionHandler('deleteHistory', async (global, actions, payload) => { return; } - const maxId = chat.lastMessage?.id; - - await callApi('deleteHistory', { chat, shouldDeleteForAll, maxId }); + await callApi('deleteHistory', { chat, shouldDeleteForAll }); const activeChat = selectCurrentMessageList(global); if (activeChat && activeChat.chatId === chatId) {