From dfd07a4f4f55ed25ff9f0fe101964396344ad95e Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 24 Jan 2025 12:02:28 +0400 Subject: [PATCH] Count all topics as one chat for outer badges. --- Telegram/SourceFiles/data/data_forum_topic.cpp | 2 -- Telegram/SourceFiles/dialogs/dialogs_common.h | 12 ------------ Telegram/SourceFiles/history/history.cpp | 14 ++++++-------- .../ui/widgets/chat_filters_tabs_strip.cpp | 10 ++-------- .../SourceFiles/window/window_filters_menu.cpp | 10 ++-------- 5 files changed, 10 insertions(+), 38 deletions(-) diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp index d8ebb396c..7e7998897 100644 --- a/Telegram/SourceFiles/data/data_forum_topic.cpp +++ b/Telegram/SourceFiles/data/data_forum_topic.cpp @@ -897,12 +897,10 @@ Dialogs::UnreadState ForumTopic::unreadStateFor( const auto muted = this->muted(); result.messages = count; result.chats = count ? 1 : 0; - result.chatsTopic = count ? 1 : 0; result.mentions = unreadMentions().has() ? 1 : 0; 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_common.h b/Telegram/SourceFiles/dialogs/dialogs_common.h index d3e16f898..4d6523f97 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_common.h +++ b/Telegram/SourceFiles/dialogs/dialogs_common.h @@ -32,14 +32,10 @@ struct UnreadState { int messagesMuted = 0; 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; @@ -48,14 +44,10 @@ struct UnreadState { messagesMuted += other.messagesMuted; 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; } @@ -64,14 +56,10 @@ struct UnreadState { messagesMuted -= other.messagesMuted; 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 75047ade1..7393dee65 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -85,12 +85,9 @@ using UpdateFlag = Data::HistoryUpdate::Flag; [[nodiscard]] Dialogs::UnreadState AdjustedForumUnreadState( Dialogs::UnreadState state) { - if (state.chatsTopic) { - state.forums = 1; - if (state.chatsTopic == state.chatsTopicMuted) { - state.forumsMuted = 1; - } - } + const auto allMuted = (state.chats == state.chatsMuted); + state.chatsMuted = (state.chats && allMuted) ? 1 : 0; + state.chats = state.chats ? 1 : 0; return state; } @@ -2229,7 +2226,7 @@ Dialogs::BadgesState History::chatListBadgesState() const { if (const auto forum = peer->forum()) { return adjustBadgesStateByFolder( Dialogs::BadgesForUnread( - AdjustedForumUnreadState(forum->topicsList()->unreadState()), + forum->topicsList()->unreadState(), Dialogs::CountInBadge::Chats, Dialogs::IncludeInBadge::UnmutedOrAll)); } @@ -3103,7 +3100,8 @@ void History::forumChanged(Data::Forum *old) { forum->topicsList()->unreadStateChanges( ) | rpl::filter([=] { return (_flags & Flag::IsForum) && inChatList(); - }) | rpl::map(AdjustedForumUnreadState + }) | 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 fd8986458..64cd5eb39 100644 --- a/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp +++ b/Telegram/SourceFiles/ui/widgets/chat_filters_tabs_strip.cpp @@ -237,14 +237,8 @@ not_null AddChatFiltersTabsStrip( ) | rpl::start_with_next([=]( const Dialogs::UnreadState &state, bool includeMuted) { - const auto chats = state.chatsTopic - ? (state.chats - state.chatsTopic + state.forums) - : state.chats; - const auto chatsMuted = state.chatsTopicMuted - ? (state.chatsMuted - - state.chatsTopicMuted - + state.forumsMuted) - : state.chatsMuted; + const auto chats = state.chats; + const auto chatsMuted = state.chatsMuted; const auto muted = (chatsMuted + state.marksMuted); const auto count = (chats + state.marks) - (includeMuted ? 0 : muted); diff --git a/Telegram/SourceFiles/window/window_filters_menu.cpp b/Telegram/SourceFiles/window/window_filters_menu.cpp index d9ef9fbc2..829a84856 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.cpp +++ b/Telegram/SourceFiles/window/window_filters_menu.cpp @@ -286,14 +286,8 @@ base::unique_qptr FiltersMenu::prepareButton( ) | rpl::start_with_next([=]( const Dialogs::UnreadState &state, bool includeMuted) { - const auto chats = state.chatsTopic - ? (state.chats - state.chatsTopic + state.forums) - : state.chats; - const auto chatsMuted = state.chatsTopicMuted - ? (state.chatsMuted - - state.chatsTopicMuted - + state.forumsMuted) - : state.chatsMuted; + const auto chats = state.chats; + const auto chatsMuted = state.chatsMuted; const auto muted = (chatsMuted + state.marksMuted); const auto count = (chats + state.marks) - (includeMuted ? 0 : muted);