2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Count unread marks in non-fully loaded folders.

This commit is contained in:
John Preston
2019-04-24 19:28:01 +04:00
parent 4c571f5bff
commit 5f62c2100c
6 changed files with 109 additions and 156 deletions

View File

@@ -41,18 +41,50 @@ struct PositionChange {
};
struct UnreadState {
std::optional<int> messagesCount;
int messagesCountMuted = 0;
int chatsCount = 0;
int chatsCountMuted = 0;
bool mark = false;
bool markMuted = false;
int messages = 0;
int messagesMuted = 0;
int chats = 0;
int chatsMuted = 0;
int marks = 0;
int marksMuted = 0;
bool known = false;
UnreadState &operator+=(const UnreadState &other) {
messages += other.messages;
messagesMuted += other.messagesMuted;
chats += other.chats;
chatsMuted += other.chatsMuted;
marks += other.marks;
marksMuted += other.marksMuted;
return *this;
}
UnreadState &operator-=(const UnreadState &other) {
messages -= other.messages;
messagesMuted -= other.messagesMuted;
chats -= other.chats;
chatsMuted -= other.chatsMuted;
marks -= other.marks;
marksMuted -= other.marksMuted;
return *this;
}
bool empty() const {
return !messagesCount.value_or(0) && !chatsCount && !mark;
return !messages && !chats && !marks;
}
};
inline UnreadState operator+(const UnreadState &a, const UnreadState &b) {
auto result = a;
result += b;
return result;
}
inline UnreadState operator-(const UnreadState &a, const UnreadState &b) {
auto result = a;
result -= b;
return result;
}
class Entry {
public:
Entry(not_null<Data::Session*> owner, const Key &key);