mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 14:38:15 +00:00
Fix possible negative folder counters.
This commit is contained in:
@@ -1983,13 +1983,17 @@ bool History::unreadCountKnown() const {
|
|||||||
return _unreadCount.has_value();
|
return _unreadCount.has_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool History::useMyUnreadInParent() const {
|
||||||
|
return !isForum() && !amMonoforumAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
void History::setUnreadCount(int newUnreadCount) {
|
void History::setUnreadCount(int newUnreadCount) {
|
||||||
Expects(folderKnown());
|
Expects(folderKnown());
|
||||||
|
|
||||||
if (_unreadCount == newUnreadCount) {
|
if (_unreadCount == newUnreadCount) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto notifier = unreadStateChangeNotifier(!isForum());
|
const auto notifier = unreadStateChangeNotifier(useMyUnreadInParent());
|
||||||
_unreadCount = newUnreadCount;
|
_unreadCount = newUnreadCount;
|
||||||
|
|
||||||
const auto lastOutgoing = [&] {
|
const auto lastOutgoing = [&] {
|
||||||
@@ -2028,7 +2032,7 @@ void History::setUnreadMark(bool unread) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto notifier = unreadStateChangeNotifier(
|
const auto notifier = unreadStateChangeNotifier(
|
||||||
!unreadCount() && !isForum());
|
useMyUnreadInParent() && !unreadCount());
|
||||||
Thread::setUnreadMarkFlag(unread);
|
Thread::setUnreadMarkFlag(unread);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2060,9 +2064,9 @@ void History::setMuted(bool muted) {
|
|||||||
if (this->muted() == muted) {
|
if (this->muted() == muted) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
const auto state = isForum()
|
const auto state = useMyUnreadInParent()
|
||||||
? Dialogs::BadgesState()
|
? computeBadgesState()
|
||||||
: computeBadgesState();
|
: Dialogs::BadgesState();
|
||||||
const auto notify = (state.unread || state.reaction);
|
const auto notify = (state.unread || state.reaction);
|
||||||
const auto notifier = unreadStateChangeNotifier(notify);
|
const auto notifier = unreadStateChangeNotifier(notify);
|
||||||
Thread::setMuted(muted);
|
Thread::setMuted(muted);
|
||||||
|
@@ -608,6 +608,7 @@ private:
|
|||||||
|
|
||||||
void hasUnreadMentionChanged(bool has) override;
|
void hasUnreadMentionChanged(bool has) override;
|
||||||
void hasUnreadReactionChanged(bool has) override;
|
void hasUnreadReactionChanged(bool has) override;
|
||||||
|
[[nodiscard]] bool useMyUnreadInParent() const;
|
||||||
|
|
||||||
const std::unique_ptr<HistoryMainElementDelegateMixin> _delegateMixin;
|
const std::unique_ptr<HistoryMainElementDelegateMixin> _delegateMixin;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user