mirror of
https://github.com/kotatogram/kotatogram-desktop
synced 2025-08-31 14:45:14 +00:00
Update API: support "All Chats" reordering.
This commit is contained in:
@@ -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)) {
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user