diff --git a/Telegram/SourceFiles/core/click_handler_types.cpp b/Telegram/SourceFiles/core/click_handler_types.cpp index a4bdf6756..abfecd48d 100644 --- a/Telegram/SourceFiles/core/click_handler_types.cpp +++ b/Telegram/SourceFiles/core/click_handler_types.cpp @@ -69,6 +69,7 @@ bool UrlRequiresConfirmation(const QUrl &url) { "|t\\.me" "|te\\.?legra\\.ph" "|graph\\.org" + "|fragment\\.com" "|telesco\\.pe" ")$", url.host(), diff --git a/Telegram/SourceFiles/data/data_thread.cpp b/Telegram/SourceFiles/data/data_thread.cpp index 9efa9db9d..1e48ef0a7 100644 --- a/Telegram/SourceFiles/data/data_thread.cpp +++ b/Telegram/SourceFiles/data/data_thread.cpp @@ -37,6 +37,11 @@ const PeerNotifySettings &Thread::notify() const { return const_cast(this)->notify(); } +bool Thread::canWrite() const { + const auto topic = asTopic(); + return topic ? topic->canWrite() : peer()->canWrite(); +} + void Thread::setUnreadThingsKnown() { _flags |= Flag::UnreadThingsKnown; } diff --git a/Telegram/SourceFiles/data/data_thread.h b/Telegram/SourceFiles/data/data_thread.h index 9f3203bc2..e4f29ebe4 100644 --- a/Telegram/SourceFiles/data/data_thread.h +++ b/Telegram/SourceFiles/data/data_thread.h @@ -66,6 +66,7 @@ public: [[nodiscard]] PeerNotifySettings ¬ify(); [[nodiscard]] const PeerNotifySettings ¬ify() const; + [[nodiscard]] bool canWrite() const; void setUnreadThingsKnown(); [[nodiscard]] HistoryUnreadThings::Proxy unreadMentions(); [[nodiscard]] HistoryUnreadThings::ConstProxy unreadMentions() const; diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 53d662ceb..084178ad7 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -4618,13 +4618,13 @@ void HistoryWidget::showMembersDropdown() { } bool HistoryWidget::pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms) { if (!_tabbedPanel) { return true; - } else if (!peer->canWrite()) { + } else if (!thread->canWrite()) { Core::App().settings().setTabbedReplacedWithInfo(true); - controller()->showPeerInfo(peer, params.withThirdColumn()); + controller()->showPeerInfo(thread, params.withThirdColumn()); return false; } Core::App().settings().setTabbedReplacedWithInfo(false); @@ -4670,7 +4670,7 @@ bool HistoryWidget::preventsClose(Fn &&continueCallback) const { } void HistoryWidget::toggleTabbedSelectorMode() { - if (!_peer) { + if (!_history) { return; } if (_tabbedPanel) { @@ -4679,7 +4679,7 @@ void HistoryWidget::toggleTabbedSelectorMode() { Core::App().settings().setTabbedSelectorSectionEnabled(true); Core::App().saveSettingsDelayed(); pushTabbedSelectorToThirdSection( - _peer, + _history, Window::SectionShow::Way::ClearStack); } else { _tabbedPanel->toggleAnimated(); diff --git a/Telegram/SourceFiles/history/history_widget.h b/Telegram/SourceFiles/history/history_widget.h index 845a70129..54a64e45e 100644 --- a/Telegram/SourceFiles/history/history_widget.h +++ b/Telegram/SourceFiles/history/history_widget.h @@ -269,7 +269,7 @@ public: // Tabbed selector management. bool pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms) override; bool returnTabbedSelector() override; diff --git a/Telegram/SourceFiles/history/view/controls/compose_controls_common.h b/Telegram/SourceFiles/history/view/controls/compose_controls_common.h index 971739734..0b6620612 100644 --- a/Telegram/SourceFiles/history/view/controls/compose_controls_common.h +++ b/Telegram/SourceFiles/history/view/controls/compose_controls_common.h @@ -35,6 +35,7 @@ struct SendActionUpdate { struct SetHistoryArgs { required history; + MsgId topicRootId = 0; Fn showSlowmodeError; rpl::producer slowmodeSecondsLeft; rpl::producer sendDisabledBySlowmode; diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp index ca3ed55a9..5f6e1fd18 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.cpp @@ -29,6 +29,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_user.h" #include "data/data_chat.h" #include "data/data_channel.h" +#include "data/data_forum_topic.h" #include "data/stickers/data_stickers.h" #include "data/stickers/data_custom_emoji.h" #include "data/data_web_page.h" @@ -893,6 +894,7 @@ void ComposeControls::setHistory(SetHistoryArgs &&args) { Expects(!_history && *args.history); _showSlowmodeError = std::move(args.showSlowmodeError); + _topicRootId = args.topicRootId; _slowmodeSecondsLeft = rpl::single(0) | rpl::then(std::move(args.slowmodeSecondsLeft)); _sendDisabledBySlowmode = rpl::single(false) @@ -2287,7 +2289,7 @@ void ComposeControls::escape() { } bool ComposeControls::pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms) { if (!_tabbedPanel) { return true; @@ -2344,8 +2346,11 @@ void ComposeControls::toggleTabbedSelectorMode() { && !_window->adaptive().isOneColumn()) { Core::App().settings().setTabbedSelectorSectionEnabled(true); Core::App().saveSettingsDelayed(); + const auto topic = _topicRootId + ? _history->peer->forumTopicFor(_topicRootId) + : nullptr; pushTabbedSelectorToThirdSection( - _history->peer, + (topic ? topic : (Data::Thread*)_history), Window::SectionShow::Way::ClearStack); } else { _tabbedPanel->toggleAnimated(); diff --git a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h index a37652048..de30d404d 100644 --- a/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h +++ b/Telegram/SourceFiles/history/view/controls/history_view_compose_controls.h @@ -143,7 +143,7 @@ public: void setMimeDataHook(MimeDataHook hook); bool pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms); bool returnTabbedSelector(); @@ -291,6 +291,7 @@ private: rpl::variable _sendDisabledBySlowmode; rpl::variable> _writeRestriction; rpl::variable _hidden; + MsgId _topicRootId = 0; Mode _mode = Mode::Normal; const std::unique_ptr _wrap; diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index a0a7f0291..cc567076e 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -1556,9 +1556,11 @@ void RepliesWidget::setInternalState( } bool RepliesWidget::pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms) { - return _composeControls->pushTabbedSelectorToThirdSection(peer, params); + return _composeControls->pushTabbedSelectorToThirdSection( + thread, + params); } bool RepliesWidget::returnTabbedSelector() { diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_replies_section.h index 3756dc416..362c27ac2 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.h @@ -108,7 +108,7 @@ public: // Tabbed selector management. bool pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms) override; bool returnTabbedSelector() override; diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index 7d224e04b..468e081e0 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -920,9 +920,11 @@ void ScheduledWidget::setInternalState( } bool ScheduledWidget::pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms) { - return _composeControls->pushTabbedSelectorToThirdSection(peer, params); + return _composeControls->pushTabbedSelectorToThirdSection( + thread, + params); } bool ScheduledWidget::returnTabbedSelector() { diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h index f789f263c..eee84054e 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.h +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.h @@ -91,7 +91,7 @@ public: // Tabbed selector management. bool pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const Window::SectionShow ¶ms) override; bool returnTabbedSelector() override; diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index 62a3044eb..18b93a112 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -380,7 +380,10 @@ void TopBarWidget::toggleInfoSection() { Core::App().saveSettingsDelayed(); if (isThreeColumn) { _controller->showSection( - Info::Memento::Default(_activeChat.key.peer()), + (_activeChat.key.topic() + ? std::make_shared( + _activeChat.key.topic()) + : Info::Memento::Default(_activeChat.key.peer())), Window::SectionShow().withThirdColumn()); } else { _controller->resizeForThirdSection(); @@ -1009,12 +1012,17 @@ void TopBarWidget::updateControlsVisibility() { : (section == Section::ChatsList) ? (_activeChat.key.peer() && _activeChat.key.peer()->isForum()) : false); + const auto hasInfo = !_activeChat.key.folder() + && (section == Section::History + ? true + : (section == Section::Replies) + ? (_activeChat.key.topic() != nullptr) + : false); updateSearchVisibility(); _menuToggle->setVisible(hasMenu && !_chooseForReportReason && !_narrowMode); - _infoToggle->setVisible(historyMode - && !_activeChat.key.folder() + _infoToggle->setVisible(hasInfo && !isOneColumn && _controller->canShowThirdSection() && !_chooseForReportReason); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index a213e2df7..f99070d25 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -2194,16 +2194,24 @@ void MainWidget::updateControlsGeometry() { anim::type::instant, anim::activation::background); const auto active = _controller->activeChatCurrent(); - if (const auto peer = active.peer()) { + if (const auto thread = active.thread()) { if (Core::App().settings().tabbedSelectorSectionEnabled()) { if (_mainSection) { - _mainSection->pushTabbedSelectorToThirdSection(peer, params); + _mainSection->pushTabbedSelectorToThirdSection( + thread, + params); } else { - _history->pushTabbedSelectorToThirdSection(peer, params); + _history->pushTabbedSelectorToThirdSection( + thread, + params); } } else if (Core::App().settings().thirdSectionInfoEnabled()) { _controller->showSection( - Info::Memento::Default(peer), + (thread->asTopic() + ? std::make_shared( + thread->asTopic()) + : Info::Memento::Default( + thread->asHistory()->peer)), params.withThirdColumn()); } } @@ -2491,11 +2499,11 @@ void MainWidget::updateThirdColumnToCurrentChat( thirdSectionForCurrentMainSection(key), params.withThirdColumn()); }; - auto switchTabbedFast = [&](not_null peer) { + auto switchTabbedFast = [&](not_null thread) { saveOldThirdSection(); return _mainSection - ? _mainSection->pushTabbedSelectorToThirdSection(peer, params) - : _history->pushTabbedSelectorToThirdSection(peer, params); + ? _mainSection->pushTabbedSelectorToThirdSection(thread, params) + : _history->pushTabbedSelectorToThirdSection(thread, params); }; if (isThreeColumn() && settings.tabbedSelectorSectionEnabled() @@ -2505,8 +2513,8 @@ void MainWidget::updateThirdColumnToCurrentChat( settings.setTabbedSelectorSectionEnabled(true); settings.setTabbedReplacedWithInfo(true); } else if (settings.tabbedReplacedWithInfo() - && key.history() - && switchTabbedFast(key.history()->peer)) { + && key.thread() + && switchTabbedFast(key.thread())) { settings.setTabbedReplacedWithInfo(false); } } else { diff --git a/Telegram/SourceFiles/window/section_widget.h b/Telegram/SourceFiles/window/section_widget.h index dec35d6df..58579ec13 100644 --- a/Telegram/SourceFiles/window/section_widget.h +++ b/Telegram/SourceFiles/window/section_widget.h @@ -18,6 +18,7 @@ class PeerData; namespace Data { struct ReactionId; +class ForumTopic; } // namespace Data namespace Main { @@ -58,7 +59,7 @@ public: // Tabbed selector management. virtual bool pushTabbedSelectorToThirdSection( - not_null peer, + not_null thread, const SectionShow ¶ms) { return false; }