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

Count unread replies locally when possible.

This commit is contained in:
John Preston
2021-08-30 19:22:16 +03:00
parent c39024c7fd
commit 52a6282eb9
5 changed files with 62 additions and 9 deletions

View File

@@ -2360,6 +2360,23 @@ void Session::notifyUnreadBadgeChanged() {
_unreadBadgeChanges.fire({});
}
std::optional<int> Session::countUnreadRepliesLocally(
not_null<HistoryItem*> root,
MsgId afterId) const {
auto result = std::optional<int>();
_unreadRepliesCountRequests.fire({
.root = root,
.afterId = afterId,
.result = &result,
});
return result;
}
auto Session::unreadRepliesCountRequests() const
-> rpl::producer<UnreadRepliesCountRequest> {
return _unreadRepliesCountRequests.events();
}
int Session::computeUnreadBadge(const Dialogs::UnreadState &state) const {
const auto all = Core::App().settings().includeMutedCounter();
return std::max(state.marks - (all ? 0 : state.marksMuted), 0)