From a6518535347f2612268e78bccf9aef14c7927a8c Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 5 Sep 2025 21:53:53 +0400 Subject: [PATCH] Add thread phrases instead of topic. --- Telegram/Resources/langs/lang.strings | 8 ++++++++ .../boxes/peers/edit_forum_topic_box.cpp | 11 +++++++++-- Telegram/SourceFiles/data/data_forum_topic.cpp | 2 +- Telegram/SourceFiles/history/history_item.cpp | 9 ++++++--- .../history/view/history_view_about_view.cpp | 2 +- .../history/view/history_view_element.cpp | 7 ++++--- .../info/profile/info_profile_actions.cpp | 4 +++- .../info/profile/info_profile_widget.cpp | 6 ++++-- Telegram/SourceFiles/window/window_peer_menu.cpp | 16 ++++++++++++---- 9 files changed, 48 insertions(+), 17 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 53bdb4bcb1..d4b3a351d1 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1625,6 +1625,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_info_group_title" = "Group Info"; "lng_info_channel_title" = "Channel Info"; "lng_info_topic_title" = "Topic Info"; +"lng_info_thread_title" = "Thread Info"; "lng_profile_enable_notifications" = "Notifications"; "lng_profile_send_message" = "Send Message"; "lng_profile_open_app" = "Open App"; @@ -2282,6 +2283,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_action_topic_hidden" = "\"{topic}\" was hidden"; "lng_action_topic_unhidden" = "\"{topic}\" was unhidden"; "lng_action_topic_placeholder" = "topic"; +"lng_action_topic_bot_thread" = "thread"; "lng_action_topic_renamed" = "{from} renamed the {link} to \"{title}\""; "lng_action_topic_icon_changed" = "{from} changed the {link} icon to {emoji}"; "lng_action_topic_icon_removed" = "{from} removed the {link} icon"; @@ -2582,6 +2584,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_bot_new_chat" = "New Chat"; "lng_bot_new_thread_title" = "New Thread"; "lng_bot_new_thread_about" = "Type any message to create a new thread."; +"lng_bot_show_threads_list" = "Show Threads List"; "lng_attach_failed" = "Failed"; "lng_attach_file" = "File"; @@ -4363,6 +4366,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_context_view_group" = "View group info"; "lng_context_view_channel" = "View channel info"; "lng_context_view_topic" = "View topic info"; +"lng_context_view_thread" = "View thread info"; "lng_context_hide_psa" = "Hide this announcement"; "lng_context_pin_to_top" = "Pin"; "lng_context_unpin_from_top" = "Unpin"; @@ -6447,6 +6451,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_ringtones_error_max_size" = "Sorry, but your file is too big. The maximum size for ringtones is {size}."; "lng_ringtones_error_max_duration" = "Sorry, but your file is too long. The maximum duration for ringtones is {duration}."; +"lng_bot_thread_edit" = "Edit Thread"; +"lng_bot_thread_title" = "Thread Name"; +"lng_bot_thread_choose_title_and_icon" = "Choose a thread name and icon"; + "lng_forum_topic_new" = "New Topic"; "lng_forum_topic_edit" = "Edit Topic"; "lng_forum_topic_title" = "Topic Name"; diff --git a/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp index bd33dd53aa..aee6a5248b 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp @@ -410,9 +410,12 @@ void EditForumTopicBox( const auto topic = (!creating && forum->peer->forum()) ? forum->peer->forum()->topicFor(rootId) : nullptr; + const auto bot = forum->peer->isBot(); const auto created = topic && !topic->creating(); box->setTitle(creating ? tr::lng_forum_topic_new() + : bot + ? tr::lng_bot_thread_edit() : tr::lng_forum_topic_edit()); box->setMaxHeight(st::editTopicMaxHeight); @@ -440,7 +443,9 @@ void EditForumTopicBox( object_ptr( box, st::defaultInputField, - tr::lng_forum_topic_title(), + (bot + ? tr::lng_bot_thread_title() + : tr::lng_forum_topic_title()), topic ? topic->title() : QString()), st::editTopicTitleMargin); box->setFocusCallback([=] { @@ -492,7 +497,9 @@ void EditForumTopicBox( }, title->lifetime()); if (!topic || !topic->isGeneral()) { - Ui::AddDividerText(top, tr::lng_forum_choose_title_and_icon()); + Ui::AddDividerText(top, bot + ? tr::lng_bot_thread_choose_title_and_icon() + : tr::lng_forum_choose_title_and_icon()); box->setScrollStyle(st::reactPanelScroll); diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp index 35a3a662c9..1dfa893bf4 100644 --- a/Telegram/SourceFiles/data/data_forum_topic.cpp +++ b/Telegram/SourceFiles/data/data_forum_topic.cpp @@ -333,7 +333,7 @@ bool ForumTopic::canDelete() const { } bool ForumTopic::canToggleClosed() const { - return !creating() && canEdit(); + return !creating() && canEdit() && !_forum->peer()->isBot(); } bool ForumTopic::canTogglePinned() const { diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index 2161ac49d0..b736e747d9 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -5519,6 +5519,9 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { auto prepareTopicEdit = [&](const MTPDmessageActionTopicEdit &action) { auto result = PreparedServiceText(); + const auto linkText = history()->peer->isBot() + ? tr::lng_action_topic_bot_thread(tr::now) + : tr::lng_action_topic_placeholder(tr::now); if (const auto closed = action.vclosed()) { result.text = { mtpIsTrue(*closed) ? tr::lng_action_topic_closed_inside(tr::now) @@ -5536,7 +5539,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { lt_from, fromLinkText(), // Link 1. lt_link, - { tr::lng_action_topic_placeholder(tr::now) }, + { linkText }, lt_emoji, Data::SingleCustomEmoji(iconId), Ui::Text::WithEntities); @@ -5547,7 +5550,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { lt_from, fromLinkText(), // Link 1. lt_link, - { tr::lng_action_topic_placeholder(tr::now) }, + { linkText }, Ui::Text::WithEntities); } } @@ -5558,7 +5561,7 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) { lt_from, fromLinkText(), // Link 1. lt_link, - { tr::lng_action_topic_placeholder(tr::now) }, + { linkText }, lt_title, Data::ForumTopicIconWithTitle( topicRootId(), diff --git a/Telegram/SourceFiles/history/view/history_view_about_view.cpp b/Telegram/SourceFiles/history/view/history_view_about_view.cpp index cd5e612c46..d97927af6e 100644 --- a/Telegram/SourceFiles/history/view/history_view_about_view.cpp +++ b/Telegram/SourceFiles/history/view/history_view_about_view.cpp @@ -371,7 +371,7 @@ auto GenerateNewBotThread( push(std::make_unique()); parent->addVerticalMargins( - st::newBotThreadTopSkip, + st::newBotThreadTopSkip - st::msgServiceMargin.top(), st::msgServiceMargin.top()); }; } diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 2c84640e28..4a59340a17 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -1217,9 +1217,10 @@ auto Element::contextDependentServiceText() -> TextWithLinks { return Ui::Text::Link(from->name(), index); }; const auto placeholderLink = [&] { - return Ui::Text::Link( - tr::lng_action_topic_placeholder(tr::now), - topicUrl); + const auto linkText = history()->peer->isBot() + ? tr::lng_action_topic_bot_thread(tr::now) + : tr::lng_action_topic_placeholder(tr::now); + return Ui::Text::Link(linkText, topicUrl); }; const auto wrapTopic = [&]( const QString &title, diff --git a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp index 211b2075c4..5115eddcb4 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_actions.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_actions.cpp @@ -2158,7 +2158,9 @@ void DetailsFiller::addShowTopicsListButton( }; AddMainButton( _wrap, - tr::lng_forum_show_topics_list(), + (forum->peer()->isBot() + ? tr::lng_bot_show_threads_list() + : tr::lng_forum_show_topics_list()), std::move(showTopicsVisible), callback, tracker); diff --git a/Telegram/SourceFiles/info/profile/info_profile_widget.cpp b/Telegram/SourceFiles/info/profile/info_profile_widget.cpp index 6ba4a1118c..3399b4f76d 100644 --- a/Telegram/SourceFiles/info/profile/info_profile_widget.cpp +++ b/Telegram/SourceFiles/info/profile/info_profile_widget.cpp @@ -108,8 +108,10 @@ void Widget::setInnerFocus() { } rpl::producer Widget::title() { - if (controller()->key().topic()) { - return tr::lng_info_topic_title(); + if (const auto topic = controller()->key().topic()) { + return topic->peer()->isBot() + ? tr::lng_info_thread_title() + : tr::lng_info_topic_title(); } else if (controller()->key().sublist() && controller()->key().sublist()->parentChat()) { return tr::lng_profile_direct_messages(); diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index a573481e00..e6a8b199ef 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -484,7 +484,10 @@ void Filler::addToggleTopicClosed() { } const auto closed = _topic->closed(); const auto weak = base::make_weak(_topic); - _addAction(closed ? tr::lng_forum_topic_reopen(tr::now) : tr::lng_forum_topic_close(tr::now), [=] { + const auto text = closed + ? tr::lng_forum_topic_reopen(tr::now) + : tr::lng_forum_topic_close(tr::now); + _addAction(text, [=] { if (const auto topic = weak.get()) { topic->setClosedAndSave(!closed); } @@ -575,7 +578,9 @@ void Filler::addInfo() { const auto controller = _controller; const auto weak = base::make_weak(_thread); const auto text = _thread->asTopic() - ? tr::lng_context_view_topic(tr::now) + ? (_thread->peer()->isBot() + ? tr::lng_context_view_thread(tr::now) + : tr::lng_context_view_topic(tr::now)) : (infoPeer->isChat() || infoPeer->isMegagroup()) ? tr::lng_context_view_group(tr::now) : infoPeer->isUser() @@ -1092,7 +1097,10 @@ void Filler::addManageTopic() { const auto history = _topic->history(); const auto rootId = _topic->rootId(); const auto navigation = _controller; - _addAction(tr::lng_forum_topic_edit(tr::now), [=] { + const auto text = _topic->forum()->peer()->isBot() + ? tr::lng_bot_thread_edit(tr::now) + : tr::lng_forum_topic_edit(tr::now); + _addAction(text, [=] { navigation->show( Box(EditForumTopicBox, navigation, history, rootId)); }, &st::menuIconEdit); @@ -1366,7 +1374,7 @@ void Filler::fill() { } void Filler::addCreateTopic() { - if (!_peer || !_peer->canCreateTopics()) { + if (!_peer || !_peer->canCreateTopics() || _peer->isBot()) { return; } const auto peer = _peer;