2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Add unread counter from feed to common counter.

This commit is contained in:
John Preston
2018-02-20 20:53:55 +03:00
parent 17a4d19beb
commit 336e691dbc
5 changed files with 72 additions and 27 deletions

View File

@@ -162,6 +162,29 @@ int Histories::unreadBadge() const {
return _unreadFull - (Global::IncludeMuted() ? 0 : _unreadMuted);
}
int Histories::unreadMutedCount() const {
return _unreadMuted;
}
void Histories::unreadIncrement(int count, bool muted) {
_unreadFull += count;
if (muted) {
_unreadMuted += count;
}
if (!muted || Global::IncludeMuted()) {
Notify::unreadCounterUpdated();
}
}
void Histories::unreadMuteChanged(int count, bool muted) {
if (muted) {
_unreadMuted += count;
} else {
_unreadMuted -= count;
}
Notify::unreadCounterUpdated();
}
bool Histories::unreadOnlyMuted() const {
return Global::IncludeMuted() ? (_unreadMuted >= _unreadFull) : false;
}
@@ -1642,9 +1665,6 @@ void History::setUnreadCount(int newUnreadCount) {
App::histories().unreadIncrement(
unreadCountDelta ? *unreadCountDelta : newUnreadCount,
mute());
if (!mute() || Global::IncludeMuted()) {
Notify::unreadCounterUpdated();
}
}
if (const auto main = App::main()) {
main->unreadCountChanged(this);
@@ -2580,7 +2600,6 @@ void History::changedInChatListHook(Dialogs::Mode list, bool added) {
if (list == Dialogs::Mode::All && unreadCount()) {
const auto delta = added ? unreadCount() : -unreadCount();
App::histories().unreadIncrement(delta, mute());
Notify::unreadCounterUpdated();
}
}