2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Fix filters unread counters.

This commit is contained in:
John Preston
2020-03-18 17:39:08 +04:00
parent 36b9911995
commit f0322cd107
2 changed files with 34 additions and 29 deletions

View File

@@ -1781,13 +1781,17 @@ void History::setUnreadCount(int newUnreadCount) {
if (_unreadCount == newUnreadCount) {
return;
}
const auto notifier = unreadStateChangeNotifier(true);
const auto wasForBadge = (unreadCountForBadge() > 0);
const auto refresher = gsl::finally([&] {
if (wasForBadge != (unreadCountForBadge() > 0)) {
owner().chatsFilters().refreshHistory(this);
}
Notify::peerUpdatedDelayed(
peer,
Notify::PeerUpdate::Flag::UnreadViewChanged);
});
const auto notifier = unreadStateChangeNotifier(true);
_unreadCount = newUnreadCount;
if (wasForBadge != (unreadCountForBadge() > 0)) {
owner().chatsFilters().refreshHistory(this);
}
if (newUnreadCount == 1) {
if (loadedAtBottom()) {
@@ -1806,9 +1810,6 @@ void History::setUnreadCount(int newUnreadCount) {
} else if (!_firstUnreadView && !_unreadBarView && loadedAtBottom()) {
calculateFirstUnreadMessage();
}
Notify::peerUpdatedDelayed(
peer,
Notify::PeerUpdate::Flag::UnreadViewChanged);
}
void History::setUnreadMark(bool unread) {
@@ -1819,17 +1820,17 @@ void History::setUnreadMark(bool unread) {
return;
}
const auto noUnreadMessages = !unreadCount();
const auto refresher = gsl::finally([&] {
if (inChatList() && noUnreadMessages) {
owner().chatsFilters().refreshHistory(this);
updateChatListEntry();
}
Notify::peerUpdatedDelayed(
peer,
Notify::PeerUpdate::Flag::UnreadViewChanged);
});
const auto notifier = unreadStateChangeNotifier(noUnreadMessages);
_unreadMark = unread;
if (inChatList() && noUnreadMessages) {
owner().chatsFilters().refreshHistory(this);
updateChatListEntry();
}
Notify::peerUpdatedDelayed(
peer,
Notify::PeerUpdate::Flag::UnreadViewChanged);
}
bool History::unreadMark() const {
@@ -1844,18 +1845,18 @@ bool History::changeMute(bool newMute) {
if (_mute == newMute) {
return false;
}
const auto refresher = gsl::finally([&] {
if (inChatList()) {
owner().chatsFilters().refreshHistory(this);
updateChatListEntry();
}
Notify::peerUpdatedDelayed(
peer,
Notify::PeerUpdate::Flag::NotificationsEnabled);
});
const auto notify = (unreadCountForBadge() > 0);
const auto notifier = unreadStateChangeNotifier(notify);
_mute = newMute;
if (inChatList()) {
owner().chatsFilters().refreshHistory(this);
updateChatListEntry();
}
Notify::peerUpdatedDelayed(
peer,
Notify::PeerUpdate::Flag::NotificationsEnabled);
return true;
}