From 3c799a5cc13922d305ee92b0e50dab4310b26f97 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 29 Nov 2022 20:21:35 +0400 Subject: [PATCH] Correctly track General editing service messages. --- Telegram/SourceFiles/data/data_forum_topic.cpp | 12 ++++++++++++ Telegram/SourceFiles/data/data_forum_topic.h | 12 ++++++++---- Telegram/SourceFiles/history/history.cpp | 3 +++ Telegram/SourceFiles/history/history_service.cpp | 10 ++++++++-- Telegram/SourceFiles/history/history_service.h | 11 +++++++++++ 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp index d2f71f1f33..4e076bb7aa 100644 --- a/Telegram/SourceFiles/data/data_forum_topic.cpp +++ b/Telegram/SourceFiles/data/data_forum_topic.cpp @@ -435,6 +435,18 @@ void ForumTopic::setClosedAndSave(bool closed) { }).send(); } +bool ForumTopic::hidden() const { + return (_flags & Flag::Hidden); +} + +void ForumTopic::setHidden(bool hidden) { + if (hidden) { + _flags |= Flag::Hidden; + } else { + _flags &= ~Flag::Hidden; + } +} + void ForumTopic::indexTitleParts() { _titleWords.clear(); _titleFirstLetters.clear(); diff --git a/Telegram/SourceFiles/data/data_forum_topic.h b/Telegram/SourceFiles/data/data_forum_topic.h index 763c62bf02..f01700ada4 100644 --- a/Telegram/SourceFiles/data/data_forum_topic.h +++ b/Telegram/SourceFiles/data/data_forum_topic.h @@ -91,6 +91,9 @@ public: void setClosed(bool closed); void setClosedAndSave(bool closed); + [[nodiscard]] bool hidden() const; + void setHidden(bool hidden); + [[nodiscard]] bool creating() const; void discard(); @@ -162,10 +165,11 @@ public: private: enum class Flag : uchar { Closed = (1 << 0), - My = (1 << 1), - HasPinnedMessages = (1 << 2), - GeneralIconActive = (1 << 3), - GeneralIconSelected = (1 << 4), + Hidden = (1 << 1), + My = (1 << 2), + HasPinnedMessages = (1 << 3), + GeneralIconActive = (1 << 4), + GeneralIconSelected = (1 << 5), }; friend inline constexpr bool is_flag_type(Flag) { return true; } using Flags = base::flags; diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index f4e7927826..82f34b5fc3 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -1216,6 +1216,9 @@ void History::applyServiceChanges( if (const auto closed = data.vclosed()) { topic->setClosed(mtpIsTrue(*closed)); } + if (const auto hidden = data.vhidden()) { + topic->setHidden(mtpIsTrue(*hidden)); + } } }, [](const auto &) { }); diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index 10c876f1db..74cf153e6a 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -1343,8 +1343,10 @@ MsgId HistoryService::topicRootId() const { if (const auto data = GetDependentData() ; data && data->topicPost && data->topId) { return data->topId; - } else if (Has()) { - return id; + } else if (const auto info = Get()) { + if (info->created()) { + return id; + } } return Data::ForumTopic::kGeneralId; } @@ -1514,6 +1516,10 @@ void HistoryService::createFromMtp(const MTPDmessageService &message) { info->closed = mtpIsTrue(*closed); info->reopened = !info->closed; } + if (const auto hidden = data.vhidden()) { + info->hidden = mtpIsTrue(*hidden); + info->unhidden = !info->hidden; + } } else { const auto &data = action.c_messageActionTopicCreate(); info->title = qs(data.vtitle()); diff --git a/Telegram/SourceFiles/history/history_service.h b/Telegram/SourceFiles/history/history_service.h index b293dbb652..506f3677d7 100644 --- a/Telegram/SourceFiles/history/history_service.h +++ b/Telegram/SourceFiles/history/history_service.h @@ -36,6 +36,17 @@ struct HistoryServiceTopicInfo bool reopened = false; bool reiconed = false; bool renamed = false; + bool hidden = false; + bool unhidden = false; + + [[nodiscard]] bool created() const { + return !closed + && !reopened + && !reiconed + && !renamed + && !hidden + && !unhidden; + } }; struct HistoryServiceGameScore