Show only channels in suggest-leave box.

This commit is contained in:
John Preston 2023-04-05 12:52:07 +04:00
parent 292e5bc3f7
commit e351ad1f3d
2 changed files with 14 additions and 6 deletions

View File

@ -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.";

View File

@ -165,6 +165,14 @@ struct FilterRow {
: result;
}
[[nodiscard]] std::vector<not_null<PeerData*>> ExtractSuggestRemoving(
const base::flat_set<not_null<History*>> &histories) {
return histories | ranges::views::filter([](
not_null<History*> history) {
return history->peer->isChannel();
}) | ranges::views::transform(&History::peer) | ranges::to_vector;
}
FilterRowButton::FilterRowButton(
not_null<QWidget*> parent,
not_null<Main::Session*> session,
@ -370,10 +378,12 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
};
const auto markForRemovalSure = [=](not_null<FilterRowButton*> button) {
const auto row = find(button);
auto suggestRemoving = row->filter.chatlist()
? ExtractSuggestRemoving(row->filter.always())
: std::vector<not_null<PeerData*>>();
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<not_null<PeerData*>> 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 {