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

@@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_chat_filters.h"
#include "data/data_peer.h"
#include "data/data_session.h"
#include "history/history.h"
#include "lang/lang_keys.h"
#include "main/main_session.h"
#include "settings/settings_common.h"
@@ -828,4 +829,15 @@ void ProcessFilterRemove(
Box<PeerListBox>(std::move(controller), std::move(initBox)));
}
[[nodiscard]] std::vector<not_null<PeerData*>> ExtractSuggestRemoving(
const Data::ChatFilter &filter) {
if (!filter.chatlist()) {
return {};
}
return filter.always() | ranges::views::filter([](
not_null<History*> history) {
return history->peer->isChannel();
}) | ranges::views::transform(&History::peer) | ranges::to_vector;
}
} // namespace Api

View File

@@ -15,6 +15,10 @@ namespace Window {
class SessionController;
} // namespace Window
namespace Data {
class ChatFilter;
} // namespace Data
namespace Api {
void SaveNewFilterPinned(
@@ -38,4 +42,7 @@ void ProcessFilterRemove(
std::vector<not_null<PeerData*>> suggest,
Fn<void(std::vector<not_null<PeerData*>>)> done);
[[nodiscard]] std::vector<not_null<PeerData*>> ExtractSuggestRemoving(
const Data::ChatFilter &filter);
} // namespace Api