Show unread badges in filters.

This commit is contained in:
John Preston 2020-03-16 16:12:40 +04:00
parent 38a744fe5b
commit 66c0d51f96
5 changed files with 34 additions and 6 deletions

View File

@ -160,8 +160,15 @@ bool ChatFilter::contains(not_null<History*> history) const {
}
return false
|| ((_flags & flag)
&& (!(_flags & Flag::NoMuted) || !history->mute())
&& (!(_flags & Flag::NoRead) || history->unreadCountForBadge())
&& (!(_flags & Flag::NoMuted)
|| !history->mute()
|| (history->hasUnreadMentions()
&& history->folderKnown()
&& !history->folder()))
&& (!(_flags & Flag::NoRead)
|| history->unreadCount()
|| history->unreadMark()
|| history->hasUnreadMentions())
&& (!(_flags & Flag::NoArchived)
|| (history->folderKnown() && !history->folder())))
|| _always.contains(history);

View File

@ -106,8 +106,9 @@ void MainList::recomputeFullListSize() {
void MainList::unreadStateChanged(
const UnreadState &wasState,
const UnreadState &nowState) {
const auto useClouded = _cloudUnreadState.known && !loaded();
const auto updateCloudUnread = _cloudUnreadState.known && wasState.known;
const auto notify = loaded() || updateCloudUnread;
const auto notify = !useClouded || wasState.known;
const auto notifier = unreadStateChangeNotifier(notify);
_unreadState += nowState - wasState;
if (updateCloudUnread) {

View File

@ -255,8 +255,12 @@ windowFiltersButton: SideBarButton(defaultSideBarButton) {
font: font(11px semibold);
}
badgeStyle: TextStyle(defaultTextStyle) {
font: font(11px semibold);
font: font(12px semibold);
}
badgeSkip: 4px;
badgeHeight: 17px;
badgeStroke: 2px;
badgePosition: point(5px, 7px);
iconPosition: point(-1px, 6px);
}
windowFiltersMainMenu: SideBarButton(windowFiltersButton) {

View File

@ -173,7 +173,23 @@ void FiltersMenu::refresh() {
_container,
title,
st)));
button->setBadge(badge);
if (id > 0) {
const auto list = filters->chatsList(id);
rpl::single(rpl::empty_value()) | rpl::then(
list->unreadStateChanges(
) | rpl::map([] { return rpl::empty_value(); })
) | rpl::start_with_next([=, raw = button.get()] {
const auto &state = list->unreadState();
const auto count = (state.chats + state.marks);
const auto muted = (state.chatsMuted + state.marksMuted);
const auto string = !count
? QString()
: (count > 99)
? "..."
: QString::number(count);
raw->setBadge(string, count == muted);
}, button->lifetime());
}
button->setActive(_session->activeChatsFilterCurrent() == id);
button->setClickedCallback([=] {
if (id >= 0) {

@ -1 +1 @@
Subproject commit d2611d7e8588759c9ecc129ce70ef0d7b2e24d6c
Subproject commit 4b6b328130d74e5c5b7de6d41603650f29277ad4