From e351ad1f3d0b27702e8dea7e1c74f92e9ac104b9 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 5 Apr 2023 12:52:07 +0400 Subject: [PATCH] Show only channels in suggest-leave box. --- Telegram/Resources/langs/lang.strings | 2 +- .../SourceFiles/settings/settings_folders.cpp | 18 +++++++++++++----- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 771f951f9..d2638a2ef 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -3614,7 +3614,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_filters_by_link_select" = "Select All"; "lng_filters_by_link_deselect" = "Deselect All"; "lng_filters_by_link_about_quit" = "You can deselect the chats you don't want to quit."; -"lng_filters_by_link_remove_button" = "Remove Folder"; +"lng_filters_by_link_remove_button" = "Remove Folder and Keep Chats"; "lng_filters_by_link_quit_button" = "Remove Folder and Chats"; "lng_filters_added_title" = "Folder {folder} Added"; "lng_filters_added_also#one" = "You also joined {count} chat."; diff --git a/Telegram/SourceFiles/settings/settings_folders.cpp b/Telegram/SourceFiles/settings/settings_folders.cpp index 6e479d58f..f6c83ce78 100644 --- a/Telegram/SourceFiles/settings/settings_folders.cpp +++ b/Telegram/SourceFiles/settings/settings_folders.cpp @@ -165,6 +165,14 @@ struct FilterRow { : result; } +[[nodiscard]] std::vector> ExtractSuggestRemoving( + const base::flat_set> &histories) { + return histories | ranges::views::filter([]( + not_null history) { + return history->peer->isChannel(); + }) | ranges::views::transform(&History::peer) | ranges::to_vector; +} + FilterRowButton::FilterRowButton( not_null parent, not_null session, @@ -370,10 +378,12 @@ void FilterRowButton::paintEvent(QPaintEvent *e) { }; const auto markForRemovalSure = [=](not_null button) { const auto row = find(button); + auto suggestRemoving = row->filter.chatlist() + ? ExtractSuggestRemoving(row->filter.always()) + : std::vector>(); if (row->removed || row->removePeersRequestId > 0) { return; - } else if (row->filter.chatlist() - && !row->filter.always().empty()) { + } else if (!suggestRemoving.empty()) { const auto chosen = crl::guard(button, [=]( std::vector> peers) { const auto row = find(button); @@ -385,9 +395,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) { controller, row->filter.title(), row->filter.iconEmoji(), - row->filter.always() | ranges::views::transform( - &History::peer - ) | ranges::to_vector, + std::move(suggestRemoving), row->suggestRemovePeers, chosen); } else {