2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Update API: support "All Chats" reordering.

This commit is contained in:
John Preston
2022-05-17 13:24:35 +04:00
parent 73bacfc650
commit fe91887ea2
13 changed files with 113 additions and 36 deletions

View File

@@ -57,6 +57,8 @@ void ChangeFilterById(
FilterId filterId,
not_null<History*> history,
bool add) {
Expects(filterId != 0);
const auto list = history->owner().chatsFilters().list();
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
if (i != end(list)) {
@@ -99,7 +101,7 @@ ChooseFilterValidator::ChooseFilterValidator(not_null<History*> history)
bool ChooseFilterValidator::canAdd() const {
for (const auto &filter : _history->owner().chatsFilters().list()) {
if (!filter.contains(_history)) {
if (filter.id() && !filter.contains(_history)) {
return true;
}
}
@@ -107,6 +109,8 @@ bool ChooseFilterValidator::canAdd() const {
}
bool ChooseFilterValidator::canRemove(FilterId filterId) const {
Expects(filterId != 0);
const auto list = _history->owner().chatsFilters().list();
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
if (i != end(list)) {
@@ -118,6 +122,8 @@ bool ChooseFilterValidator::canRemove(FilterId filterId) const {
}
bool ChooseFilterValidator::limitReached(FilterId filterId) const {
Expects(filterId != 0);
const auto list = _history->owner().chatsFilters().list();
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
const auto limit = _history->owner().pinnedChatsLimit(nullptr, filterId);
@@ -142,6 +148,10 @@ void FillChooseFilterMenu(
const auto validator = ChooseFilterValidator(history);
for (const auto &filter : history->owner().chatsFilters().list()) {
const auto id = filter.id();
if (!id) {
continue;
}
const auto contains = filter.contains(history);
const auto action = menu->addAction(filter.title(), [=] {
if (filter.contains(history)) {

View File

@@ -668,6 +668,8 @@ void EditFilterBox(
void EditExistingFilter(
not_null<Window::SessionController*> window,
FilterId id) {
Expects(id != 0);
const auto session = &window->session();
const auto &list = session->data().chatsFilters().list();
const auto i = ranges::find(list, id, &Data::ChatFilter::id);