From 9b989329d4239f11a4642c4924714d7a1fe76cd5 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 1 Jul 2025 15:59:20 +0400 Subject: [PATCH] Fix muted state of monoforums. --- Telegram/SourceFiles/data/data_saved_messages.cpp | 11 +++++++++++ Telegram/SourceFiles/data/data_saved_messages.h | 6 ++++++ Telegram/SourceFiles/history/history.cpp | 14 ++++---------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/data/data_saved_messages.cpp b/Telegram/SourceFiles/data/data_saved_messages.cpp index 12f3e870b9..1cae8972db 100644 --- a/Telegram/SourceFiles/data/data_saved_messages.cpp +++ b/Telegram/SourceFiles/data/data_saved_messages.cpp @@ -96,6 +96,17 @@ Thread *SavedMessages::activeSubsectionThread() const { return _activeSubsectionSublist; } +Dialogs::UnreadState SavedMessages::unreadStateWithParentMuted() const { + auto result = _chatsList.unreadState(); + if (_owningHistory->muted()) { + result.chatsMuted = result.chats; + result.marksMuted = result.marks; + result.messagesMuted = result.messages; + result.reactionsMuted = result.reactions; + } + return result; +} + SavedMessages::~SavedMessages() { clear(); } diff --git a/Telegram/SourceFiles/data/data_saved_messages.h b/Telegram/SourceFiles/data/data_saved_messages.h index 193dfc25d5..65f0345c7b 100644 --- a/Telegram/SourceFiles/data/data_saved_messages.h +++ b/Telegram/SourceFiles/data/data_saved_messages.h @@ -9,6 +9,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "dialogs/dialogs_main_list.h" +namespace Dialogs { +struct UnreadState; +} // namespace Dialogs + namespace Main { class Session; } // namespace Main @@ -80,6 +84,8 @@ public: void saveActiveSubsectionThread(not_null thread); Thread *activeSubsectionThread() const; + [[nodiscard]] Dialogs::UnreadState unreadStateWithParentMuted() const; + [[nodiscard]] rpl::lifetime &lifetime(); private: diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 04da9df94b..eb7d35e209 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -2369,14 +2369,8 @@ Dialogs::UnreadState History::chatListUnreadState() const { if (const auto forum = peer->forum()) { return AdjustedForumUnreadState(forum->topicsList()->unreadState()); } else if (const auto monoforum = peer->monoforum()) { - auto state = monoforum->chatsList()->unreadState(); - if (muted()) { - state.chatsMuted = state.chats; - state.marksMuted = state.marks; - state.messagesMuted = state.messages; - state.reactionsMuted = state.reactions; - } - return AdjustedForumUnreadState(state); + return AdjustedForumUnreadState( + monoforum->unreadStateWithParentMuted()); } return computeUnreadState(); } @@ -2391,9 +2385,9 @@ Dialogs::BadgesState History::chatListBadgesState() const { } else if (const auto monoforum = peer->monoforum()) { return adjustBadgesStateByFolder( Dialogs::BadgesForUnread( - monoforum->chatsList()->unreadState(), + monoforum->unreadStateWithParentMuted(), Dialogs::CountInBadge::Chats, - Dialogs::IncludeInBadge::UnmutedOrAll)); + Dialogs::IncludeInBadge::All)); } return computeBadgesState(); }