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:
@@ -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);
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user