diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp index d7ad7565a..d8ebb396c 100644 --- a/Telegram/SourceFiles/data/data_forum_topic.cpp +++ b/Telegram/SourceFiles/data/data_forum_topic.cpp @@ -902,6 +902,7 @@ Dialogs::UnreadState ForumTopic::unreadStateFor( result.reactions = unreadReactions().has() ? 1 : 0; result.messagesMuted = muted ? result.messages : 0; result.chatsMuted = muted ? result.chats : 0; + result.chatsTopicMuted = muted ? result.chats : 0; result.reactionsMuted = muted ? result.reactions : 0; result.known = known; return result; diff --git a/Telegram/SourceFiles/dialogs/dialogs_entry.h b/Telegram/SourceFiles/dialogs/dialogs_entry.h index b97044241..83935c5ba 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_entry.h +++ b/Telegram/SourceFiles/dialogs/dialogs_entry.h @@ -75,10 +75,13 @@ struct UnreadState { int chats = 0; int chatsMuted = 0; int chatsTopic = 0; + int chatsTopicMuted = 0; int marks = 0; int marksMuted = 0; int reactions = 0; int reactionsMuted = 0; + int forums = 0; + int forumsMuted = 0; int mentions = 0; bool known = false; @@ -88,10 +91,13 @@ struct UnreadState { chats += other.chats; chatsMuted += other.chatsMuted; chatsTopic += other.chatsTopic; + chatsTopicMuted += other.chatsTopicMuted; marks += other.marks; marksMuted += other.marksMuted; reactions += other.reactions; reactionsMuted += other.reactionsMuted; + forums += other.forums; + forumsMuted += other.forumsMuted; mentions += other.mentions; return *this; } @@ -101,10 +107,13 @@ struct UnreadState { chats -= other.chats; chatsMuted -= other.chatsMuted; chatsTopic -= other.chatsTopic; + chatsTopicMuted -= other.chatsTopicMuted; marks -= other.marks; marksMuted -= other.marksMuted; reactions -= other.reactions; reactionsMuted -= other.reactionsMuted; + forums -= other.forums; + forumsMuted -= other.forumsMuted; mentions -= other.mentions; return *this; } diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 56ca12032..8c9be9ce7 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -81,6 +81,17 @@ using UpdateFlag = Data::HistoryUpdate::Flag; return fields; } +[[nodiscard]] Dialogs::UnreadState AdjustedForumUnreadState( + Dialogs::UnreadState state) { + if (state.chatsTopic) { + state.forums = 1; + if (state.chatsTopic == state.chatsTopicMuted) { + state.forumsMuted = 1; + } + } + return state; +} + } // namespace History::History(not_null owner, PeerId peerId) @@ -2195,7 +2206,7 @@ History *History::migrateSibling() const { Dialogs::UnreadState History::chatListUnreadState() const { if (const auto forum = peer->forum()) { - return forum->topicsList()->unreadState(); + return AdjustedForumUnreadState(forum->topicsList()->unreadState()); } return computeUnreadState(); } @@ -2204,7 +2215,7 @@ Dialogs::BadgesState History::chatListBadgesState() const { if (const auto forum = peer->forum()) { return adjustBadgesStateByFolder( Dialogs::BadgesForUnread( - forum->topicsList()->unreadState(), + AdjustedForumUnreadState(forum->topicsList()->unreadState()), Dialogs::CountInBadge::Chats, Dialogs::IncludeInBadge::UnmutedOrAll)); } @@ -3068,7 +3079,7 @@ const Data::Thread *History::threadFor(MsgId topicRootId) const { void History::forumChanged(Data::Forum *old) { if (inChatList()) { notifyUnreadStateChange(old - ? old->topicsList()->unreadState() + ? AdjustedForumUnreadState(old->topicsList()->unreadState()) : computeUnreadState()); } @@ -3078,7 +3089,8 @@ void History::forumChanged(Data::Forum *old) { forum->topicsList()->unreadStateChanges( ) | rpl::filter([=] { return (_flags & Flag::IsForum) && inChatList(); - }) | rpl::start_with_next([=](const Dialogs::UnreadState &old) { + }) | rpl::map(AdjustedForumUnreadState + ) | rpl::start_with_next([=](const Dialogs::UnreadState &old) { notifyUnreadStateChange(old); }, forum->lifetime()); diff --git a/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp b/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp index 65e9a9de8..5bb72e1d6 100644 --- a/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp +++ b/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp @@ -338,9 +338,14 @@ not_null AddChatFiltersTabsStrip( const Dialogs::UnreadState &state, bool includeMuted) { const auto chats = state.chatsTopic - ? (state.chats - state.chatsTopic + 1) + ? (state.chats - state.chatsTopic + state.forums) : state.chats; - const auto muted = (state.chatsMuted + state.marksMuted); + const auto chatsMuted = state.chatsTopicMuted + ? (state.chatsMuted + - state.chatsTopicMuted + + state.forumsMuted) + : state.chatsMuted; + const auto muted = (chatsMuted + state.marksMuted); const auto count = (chats + state.marks) - (includeMuted ? 0 : muted); const auto isMuted = includeMuted && (count == muted); diff --git a/Telegram/SourceFiles/window/window_filters_menu.cpp b/Telegram/SourceFiles/window/window_filters_menu.cpp index d5d2fdd99..db1f15b35 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.cpp +++ b/Telegram/SourceFiles/window/window_filters_menu.cpp @@ -271,9 +271,14 @@ base::unique_qptr FiltersMenu::prepareButton( const Dialogs::UnreadState &state, bool includeMuted) { const auto chats = state.chatsTopic - ? (state.chats - state.chatsTopic + 1) + ? (state.chats - state.chatsTopic + state.forums) : state.chats; - const auto muted = (state.chatsMuted + state.marksMuted); + const auto chatsMuted = state.chatsTopicMuted + ? (state.chatsMuted + - state.chatsTopicMuted + + state.forumsMuted) + : state.chatsMuted; + const auto muted = (chatsMuted + state.marksMuted); const auto count = (chats + state.marks) - (includeMuted ? 0 : muted); const auto string = !count