2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Implement complex filter delete from context menu.

This commit is contained in:
John Preston
2023-04-05 15:06:41 +04:00
parent 6f4eef035d
commit 1a1fa5db3e
5 changed files with 112 additions and 24 deletions

View File

@@ -165,14 +165,6 @@ 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,
@@ -378,9 +370,7 @@ 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*>>();
auto suggestRemoving = Api::ExtractSuggestRemoving(row->filter);
if (row->removed || row->removePeersRequestId > 0) {
return;
} else if (!suggestRemoving.empty()) {