diff --git a/Telegram/Resources/tl/api.tl b/Telegram/Resources/tl/api.tl index d188e3293..1d57ee601 100644 --- a/Telegram/Resources/tl/api.tl +++ b/Telegram/Resources/tl/api.tl @@ -1212,6 +1212,8 @@ messages.historyImport#1662af0b id:long = messages.HistoryImport; messages.historyImportParsed#5e0fb7b9 flags:# pm:flags.0?true group:flags.1?true title:flags.2?string = messages.HistoryImportParsed; +messages.affectedFoundMessages#ef8d3e6c pts:int pts_count:int offset:int messages:Vector = messages.AffectedFoundMessages; + ---functions--- invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X; @@ -1462,7 +1464,7 @@ messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.Disc messages.readDiscussion#f731a9f4 peer:InputPeer msg_id:int read_max_id:int = Bool; messages.unpinAllMessages#f025bc8b peer:InputPeer = messages.AffectedHistory; messages.deleteChat#83247d11 chat_id:int = Bool; -messages.deletePhoneCallHistory#6cff1b45 flags:# revoke:flags.0?true = messages.AffectedHistory; +messages.deletePhoneCallHistory#f9cbe409 flags:# revoke:flags.0?true = messages.AffectedFoundMessages; messages.checkHistoryImport#43fe19f3 import_head:string = messages.HistoryImportParsed; messages.initHistoryImport#34090c3b peer:InputPeer file:InputFile media_count:int = messages.HistoryImport; messages.uploadImportedMedia#2a862092 peer:InputPeer import_id:long file_name:string media:InputMedia = MessageMedia; diff --git a/Telegram/SourceFiles/boxes/peer_list_box.h b/Telegram/SourceFiles/boxes/peer_list_box.h index b9ce4f203..6a2b87786 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.h +++ b/Telegram/SourceFiles/boxes/peer_list_box.h @@ -375,6 +375,9 @@ public: _delegate = delegate; prepare(); } + [[nodiscard]] not_null delegate() const { + return _delegate; + } void setStyleOverrides( const style::PeerList *listSt, @@ -453,9 +456,6 @@ public: virtual ~PeerListController() = default; protected: - not_null delegate() const { - return _delegate; - } PeerListSearchController *searchController() const { return _searchController.get(); } diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 68121430a..e32bf71c7 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -24,6 +24,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_media_types.h" #include "data/data_user.h" #include "boxes/confirm_box.h" +#include "base/unixtime.h" +#include "api/api_updates.h" #include "app.h" #include "apiwrap.h" #include "styles/style_layers.h" // st::boxLabel. @@ -504,16 +506,30 @@ void ClearCallsBox( using Flag = MTPmessages_DeletePhoneCallHistory::Flag; api->request(MTPmessages_DeletePhoneCallHistory( MTP_flags(revoke ? Flag::f_revoke : Flag(0)) - )).done([=](const MTPmessages_AffectedHistory &result) { - const auto offset = api->applyAffectedHistory(nullptr, result); - if (offset > 0) { - self(revoke, self); - } else { - api->session().data().destroyAllCallItems(); - if (const auto strong = weak.data()) { - strong->closeBox(); + )).done([=](const MTPmessages_AffectedFoundMessages &result) { + result.match([&]( + const MTPDmessages_affectedFoundMessages &data) { + api->applyUpdates(MTP_updates( + MTP_vector( + 1, + MTP_updateDeleteMessages( + data.vmessages(), + data.vpts(), + data.vpts_count())), + MTP_vector(), + MTP_vector(), + MTP_int(base::unixtime::now()), + MTP_int(0))); + const auto offset = data.voffset().v; + if (offset > 0) { + self(revoke, self); + } else { + api->session().data().destroyAllCallItems(); + if (const auto strong = weak.data()) { + strong->closeBox(); + } } - } + }); }).send(); }; diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 655ba1706..5edad0b6f 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -99,7 +99,10 @@ constexpr auto kMinDiffIntensity = 0.25; void ShowCallsBox(not_null window) { auto controller = std::make_unique(window); - const auto initBox = [=](not_null box) { + const auto initBox = [ + window, + controller = controller.get() + ](not_null box) { box->addButton(tr::lng_close(), [=] { box->closeBox(); }); @@ -119,9 +122,11 @@ void ShowCallsBox(not_null window) { (*menu)->addAction( tr::lng_settings_section_call_settings(tr::now), showSettings); - (*menu)->addAction( - tr::lng_call_box_clear_all(tr::now), - clearAll); + if (controller->delegate()->peerListFullRowsCount() > 0) { + (*menu)->addAction( + tr::lng_call_box_clear_all(tr::now), + clearAll); + } (*menu)->popup(QCursor::pos()); return true; });