diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 5c2e81430..7b6c43c33 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1557,9 +1557,13 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_action_topic_created_inside" = "Topic created"; "lng_action_topic_closed_inside" = "Topic closed"; "lng_action_topic_reopened_inside" = "Topic reopened"; +"lng_action_topic_hidden_inside" = "Topic hidden"; +"lng_action_topic_unhidden_inside" = "Topic unhidden"; "lng_action_topic_created" = "«{topic}» was created"; "lng_action_topic_closed" = "«{topic}» was closed"; "lng_action_topic_reopened" = "«{topic}» was reopened"; +"lng_action_topic_hidden" = "«{topic}» was hidden"; +"lng_action_topic_unhidden" = "«{topic}» was unhidden"; "lng_action_topic_placeholder" = "topic"; "lng_action_topic_renamed" = "{from} renamed the {link} to «{title}»"; "lng_action_topic_icon_changed" = "{from} changed the {link} icon to {emoji}"; @@ -3162,6 +3166,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_admin_log_topics_changed" = "{from} changed topic {topic} to {new_topic}"; "lng_admin_log_topics_closed" = "{from} closed topic {topic}"; "lng_admin_log_topics_reopened" = "{from} reopened topic {topic}"; +"lng_admin_log_topics_hidden" = "{from} hid topic {topic}"; +"lng_admin_log_topics_unhidden" = "{from} unhid topic {topic}"; "lng_admin_log_topics_deleted" = "{from} deleted topic {topic}"; "lng_admin_log_topics_pinned" = "{from} pinned topic {topic}"; "lng_admin_log_topics_unpinned" = "{from} unpinned topic {topic}"; diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp index 844a97f27..fc7c56071 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_item.cpp @@ -630,6 +630,14 @@ TextWithEntities GenerateDefaultBannedRightsChangeText( }); } +[[nodiscard]] bool IsTopicHidden(const MTPForumTopic &topic) { + return topic.match([](const MTPDforumTopic &data) { + return data.is_hidden(); + }, [](const MTPDforumTopicDeleted &) { + return false; + }); +} + [[nodiscard]] TextWithEntities GenerateTopicLink( not_null channel, const MTPForumTopic &topic) { @@ -1713,6 +1721,19 @@ void GenerateItems( nowLink, Ui::Text::WithEntities)); } + const auto wasHidden = IsTopicHidden(data.vprev_topic()); + const auto nowHidden = IsTopicHidden(data.vnew_topic()); + if (nowHidden != wasHidden) { + addSimpleServiceMessage((nowHidden + ? tr::lng_admin_log_topics_hidden + : tr::lng_admin_log_topics_unhidden)( + tr::now, + lt_from, + fromLinkText, + lt_topic, + nowLink, + Ui::Text::WithEntities)); + } }; const auto createDeleteTopic = [&](const LogDeleteTopic &data) { diff --git a/Telegram/SourceFiles/history/history_service.cpp b/Telegram/SourceFiles/history/history_service.cpp index f01683d77..9d9ea2d3b 100644 --- a/Telegram/SourceFiles/history/history_service.cpp +++ b/Telegram/SourceFiles/history/history_service.cpp @@ -674,6 +674,10 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) { result.text = { mtpIsTrue(*closed) ? tr::lng_action_topic_closed_inside(tr::now) : tr::lng_action_topic_reopened_inside(tr::now) }; + } else if (const auto hidden = action.vhidden()) { + result.text = { mtpIsTrue(*hidden) + ? tr::lng_action_topic_hidden_inside(tr::now) + : tr::lng_action_topic_unhidden_inside(tr::now) }; } else if (!action.vtitle()) { if (const auto icon = action.vicon_emoji_id()) { if (const auto iconId = icon->v) { diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 98d946cd5..b1b0783d2 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -676,16 +676,12 @@ auto Element::contextDependentServiceText() -> TextWithLinks { if (!info) { return {}; } - const auto created = !info->closed - && !info->reopened - && !info->renamed - && !info->reiconed; if (_delegate->elementContext() == Context::Replies) { - if (created) { + if (info->created()) { return { { tr::lng_action_topic_created_inside(tr::now) } }; } return {}; - } else if (created) { + } else if (info->created()) { return{}; } const auto peerId = item->history()->peer->id; @@ -750,6 +746,22 @@ auto Element::contextDependentServiceText() -> TextWithLinks { wrapParentTopic(), Ui::Text::WithEntities), }; + } else if (info->hidden) { + return { + tr::lng_action_topic_hidden( + tr::now, + lt_topic, + wrapParentTopic(), + Ui::Text::WithEntities), + }; + } else if (info->unhidden) { + return { + tr::lng_action_topic_unhidden( + tr::now, + lt_topic, + wrapParentTopic(), + Ui::Text::WithEntities), + }; } else if (info->renamed) { return { tr::lng_action_topic_renamed(