Fixed ability to remove peer from chats filter to make it empty.

This commit is contained in:
23rd 2024-11-24 10:13:47 +03:00
parent b335981621
commit aa8d543ed8
3 changed files with 15 additions and 3 deletions

View file

@ -126,9 +126,7 @@ bool ChooseFilterValidator::canRemove(FilterId filterId) const {
const auto list = _history->owner().chatsFilters().list();
const auto i = ranges::find(list, filterId, &Data::ChatFilter::id);
if (i != end(list)) {
const auto &filter = *i;
return filter.contains(_history)
&& ((filter.always().size() > 1) || filter.flags());
return Data::CanRemoveFromChatFilter(*i, _history);
}
return false;
}

View file

@ -1086,4 +1086,14 @@ void ChatFilters::checkLoadMoreChatsLists() {
}
}
bool CanRemoveFromChatFilter(
const ChatFilter &filter,
not_null<History*> history) {
using Flag = ChatFilter::Flag;
const auto flagsWithoutNoReadNoArchivedNoMuted = filter.flags()
& ~(Flag::NoRead | Flag::NoArchived | Flag::NoMuted);
return (filter.always().size() > 1 || flagsWithoutNoReadNoArchivedNoMuted)
&& filter.contains(history);
}
} // namespace Data

View file

@ -252,4 +252,8 @@ private:
};
[[nodiscard]] bool CanRemoveFromChatFilter(
const ChatFilter &filter,
not_null<History*> history);
} // namespace Data