2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-30 14:08:41 +00:00

Fix possible negative folder counters.

This commit is contained in:
John Preston
2025-07-25 13:05:41 +04:00
parent 58375f06e5
commit d458bf6be3
2 changed files with 10 additions and 5 deletions

View File

@@ -1983,13 +1983,17 @@ bool History::unreadCountKnown() const {
return _unreadCount.has_value();
}
bool History::useMyUnreadInParent() const {
return !isForum() && !amMonoforumAdmin();
}
void History::setUnreadCount(int newUnreadCount) {
Expects(folderKnown());
if (_unreadCount == newUnreadCount) {
return;
}
const auto notifier = unreadStateChangeNotifier(!isForum());
const auto notifier = unreadStateChangeNotifier(useMyUnreadInParent());
_unreadCount = newUnreadCount;
const auto lastOutgoing = [&] {
@@ -2028,7 +2032,7 @@ void History::setUnreadMark(bool unread) {
return;
}
const auto notifier = unreadStateChangeNotifier(
!unreadCount() && !isForum());
useMyUnreadInParent() && !unreadCount());
Thread::setUnreadMarkFlag(unread);
}
@@ -2060,9 +2064,9 @@ void History::setMuted(bool muted) {
if (this->muted() == muted) {
return;
} else {
const auto state = isForum()
? Dialogs::BadgesState()
: computeBadgesState();
const auto state = useMyUnreadInParent()
? computeBadgesState()
: Dialogs::BadgesState();
const auto notify = (state.unread || state.reaction);
const auto notifier = unreadStateChangeNotifier(notify);
Thread::setMuted(muted);

View File

@@ -608,6 +608,7 @@ private:
void hasUnreadMentionChanged(bool has) override;
void hasUnreadReactionChanged(bool has) override;
[[nodiscard]] bool useMyUnreadInParent() const;
const std::unique_ptr<HistoryMainElementDelegateMixin> _delegateMixin;