From ce631436bf66d48198dfcf3a53e73b949c9f2359 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 15 Nov 2022 19:12:03 +0400 Subject: [PATCH] Show non-read non-opened topics as unread. --- Telegram/SourceFiles/data/data_forum.cpp | 3 ++- Telegram/SourceFiles/data/data_forum_topic.cpp | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/data/data_forum.cpp b/Telegram/SourceFiles/data/data_forum.cpp index 93ce8ce3f..2ae50874e 100644 --- a/Telegram/SourceFiles/data/data_forum.cpp +++ b/Telegram/SourceFiles/data/data_forum.cpp @@ -47,6 +47,7 @@ Forum::Forum(not_null history) , _topicsList(&session(), {}, owner().maxPinnedChatsLimitValue(this)) { Expects(_history->peer->isChannel()); + if (_history->inChatList()) { preloadTopics(); } @@ -154,6 +155,7 @@ void Forum::requestTopics() { if (_topicsList.loaded()) { _chatsListLoadedEvents.fire({}); } + reorderLastTopics(); requestSomeStale(); }).fail([=](const MTP::Error &error) { _requestId = 0; @@ -409,7 +411,6 @@ ForumTopic *Forum::applyTopicAdded( if (!creating(rootId)) { raw->addToChatList(FilterId(), topicsList()); _chatsListChanges.fire({}); - reorderLastTopics(); } return raw; diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp index bd6e53776..f62a84f90 100644 --- a/Telegram/SourceFiles/data/data_forum_topic.cpp +++ b/Telegram/SourceFiles/data/data_forum_topic.cpp @@ -743,10 +743,15 @@ Dialogs::UnreadState ForumTopic::chatListUnreadState() const { } Dialogs::BadgesState ForumTopic::chatListBadgesState() const { - return Dialogs::BadgesForUnread( + auto result = Dialogs::BadgesForUnread( chatListUnreadState(), Dialogs::CountInBadge::Messages, Dialogs::IncludeInBadge::All); + if (!result.unread && _replies->inboxReadTillId() < 2) { + result.unread = channel()->amIn() + && (_lastKnownServerMessageId > history()->inboxReadTillId()); + } + return result; } Dialogs::UnreadState ForumTopic::unreadStateFor(