diff --git a/Telegram/SourceFiles/export/export_controller.cpp b/Telegram/SourceFiles/export/export_controller.cpp index 5c572535ce..2dbe45ffbe 100644 --- a/Telegram/SourceFiles/export/export_controller.cpp +++ b/Telegram/SourceFiles/export/export_controller.cpp @@ -42,7 +42,8 @@ public: QPointer mtproto, const MTPInputPeer &peer, int32 topicRootId, - uint64 peerId); + uint64 peerId, + const QString &topicTitle); rpl::producer state() const; @@ -149,6 +150,7 @@ private: int32 _topicRootId = 0; uint64 _topicPeerId = 0; + QString _topicTitle; rpl::lifetime _lifetime; @@ -183,11 +185,13 @@ ControllerObject::ControllerObject( QPointer mtproto, const MTPInputPeer &peer, int32 topicRootId, - uint64 peerId) + uint64 peerId, + const QString &topicTitle) : _api(mtproto, weak.runner()) , _state(PasswordCheckState{}) , _topicRootId(topicRootId) -, _topicPeerId(peerId) { +, _topicPeerId(peerId) +, _topicTitle(topicTitle) { _api.errors( ) | rpl::start_with_next([=](const MTP::Error &error) { setState(ApiErrorState{ error }); @@ -760,7 +764,7 @@ int ControllerObject::substepsInStep(Step step) const { void ControllerObject::exportTopic() { auto topicInfo = Data::DialogInfo(); topicInfo.type = Data::DialogInfo::Type::PublicSupergroup; - topicInfo.name = "Topic"; + topicInfo.name = _topicTitle.toUtf8(); topicInfo.peerId = PeerId(_topicPeerId); topicInfo.relativePath = QString(); @@ -807,6 +811,7 @@ ProcessingState ControllerObject::stateTopic( const DownloadProgress &progress) const { return prepareState(Step::Topic, [&](ProcessingState &result) { result.entityType = ProcessingState::EntityType::Topic; + result.entityName = _topicTitle; result.entityIndex = 0; result.entityCount = 1; result.itemIndex = _messagesWritten + progress.itemIndex; @@ -838,12 +843,14 @@ Controller::Controller( QPointer mtproto, const MTPInputPeer &peer, int32 topicRootId, - uint64 peerId) + uint64 peerId, + const QString &topicTitle) : _wrapped( std::move(mtproto), peer, static_cast(topicRootId), - static_cast(peerId)) { + static_cast(peerId), + topicTitle) { } rpl::producer Controller::state() const { diff --git a/Telegram/SourceFiles/export/export_controller.h b/Telegram/SourceFiles/export/export_controller.h index 018f48ae77..386c24f788 100644 --- a/Telegram/SourceFiles/export/export_controller.h +++ b/Telegram/SourceFiles/export/export_controller.h @@ -121,7 +121,8 @@ public: QPointer mtproto, const MTPInputPeer &peer, int32 topicRootId, - uint64 peerId); + uint64 peerId, + const QString &topicTitle); rpl::producer state() const; diff --git a/Telegram/SourceFiles/export/export_manager.cpp b/Telegram/SourceFiles/export/export_manager.cpp index 031fe800e3..df9f7c3c57 100644 --- a/Telegram/SourceFiles/export/export_manager.cpp +++ b/Telegram/SourceFiles/export/export_manager.cpp @@ -27,7 +27,8 @@ void Manager::start(not_null peer) { void Manager::startTopic( not_null peer, - MsgId topicRootId) { + MsgId topicRootId, + const QString &topicTitle) { if (_panel) { _panel->activatePanel(); return; @@ -36,7 +37,8 @@ void Manager::startTopic( &peer->session().mtp(), peer->input, int32(topicRootId.bare), - uint64(peer->id.value)); + uint64(peer->id.value), + topicTitle); setupPanel(&peer->session()); } diff --git a/Telegram/SourceFiles/export/export_manager.h b/Telegram/SourceFiles/export/export_manager.h index c9355f352c..0e54f6c14f 100644 --- a/Telegram/SourceFiles/export/export_manager.h +++ b/Telegram/SourceFiles/export/export_manager.h @@ -36,7 +36,8 @@ public: const MTPInputPeer &singlePeer = MTP_inputPeerEmpty()); void startTopic( not_null peer, - MsgId topicRootId); + MsgId topicRootId, + const QString &topicTitle); [[nodiscard]] rpl::producer currentView() const; [[nodiscard]] bool inProgress() const; diff --git a/Telegram/SourceFiles/export/export_settings.h b/Telegram/SourceFiles/export/export_settings.h index 587cab6200..ae2e3238bc 100644 --- a/Telegram/SourceFiles/export/export_settings.h +++ b/Telegram/SourceFiles/export/export_settings.h @@ -90,6 +90,7 @@ struct Settings { int32 singleTopicRootId = 0; uint64 singleTopicPeerId = 0; + QString singleTopicTitle; TimeId availableAt = 0; diff --git a/Telegram/SourceFiles/export/view/export_view_content.cpp b/Telegram/SourceFiles/export/view/export_view_content.cpp index 8e0cf0e550..9ea898fcac 100644 --- a/Telegram/SourceFiles/export/view/export_view_content.cpp +++ b/Telegram/SourceFiles/export/view/export_view_content.cpp @@ -142,7 +142,9 @@ Content ContentFromState( pushMain(tr::lng_export_state_chats(tr::now)); push( "topic", - u"Topic"_q, + state.entityName.isEmpty() + ? tr::lng_deleted(tr::now) + : state.entityName, (state.itemCount > 0 ? (QString::number(state.itemIndex) + " / " diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index 296c10a88d..052ac47984 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1759,7 +1759,9 @@ void PeerMenuExportTopic( not_null peer, MsgId topicRootId) { base::call_delayed(st::defaultPopupMenu.showDuration, [=] { - Core::App().exportManager().startTopic(peer, topicRootId); + const auto topic = peer->forumTopicFor(topicRootId); + const auto topicTitle = topic ? topic->title() : QString(); + Core::App().exportManager().startTopic(peer, topicRootId, topicTitle); }); }