From 230c83d2188470dead8d336f9f718b58a5e5a6b3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 6 Nov 2017 16:14:44 +0400 Subject: [PATCH] Follow group->supergroup migration in info. --- Telegram/SourceFiles/info/info_controller.cpp | 25 +++++++++++++++++++ Telegram/SourceFiles/info/info_controller.h | 1 + 2 files changed, 26 insertions(+) diff --git a/Telegram/SourceFiles/info/info_controller.cpp b/Telegram/SourceFiles/info/info_controller.cpp index d59b02519b..0b9ba93385 100644 --- a/Telegram/SourceFiles/info/info_controller.cpp +++ b/Telegram/SourceFiles/info/info_controller.cpp @@ -25,6 +25,8 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org #include "info/info_content_widget.h" #include "info/info_memento.h" #include "info/media/info_media_widget.h" +#include "observer_peer.h" +#include "window/window_controller.h" namespace Info { namespace { @@ -52,6 +54,29 @@ Controller::Controller( , _window(window) , _section(memento->section()) { updateSearchControllers(memento); + setupMigrationViewer(); +} + +void Controller::setupMigrationViewer() { + if (!_peer->isChat() && (!_peer->isChannel() || _migrated != nullptr)) { + return; + } + Notify::PeerUpdateValue(_peer, Notify::PeerUpdate::Flag::MigrationChanged) + | rpl::start_with_next([this] { + if (_peer->migrateTo() || (_peer->migrateFrom() != _migrated)) { + auto windowController = window(); + auto peerId = _peer->id; + auto section = _section; + InvokeQueued(_widget, [=] { + windowController->showSection( + Memento(peerId, section), + Window::SectionShow( + Window::SectionShow::Way::Backward, + anim::type::instant, + anim::activation::background)); + }); + } + }, lifetime()); } Wrap Controller::wrap() const { diff --git a/Telegram/SourceFiles/info/info_controller.h b/Telegram/SourceFiles/info/info_controller.h index e825f557ee..309cf9d006 100644 --- a/Telegram/SourceFiles/info/info_controller.h +++ b/Telegram/SourceFiles/info/info_controller.h @@ -133,6 +133,7 @@ private: void updateSearchControllers(not_null memento); SearchQuery produceSearchQuery(const QString &query) const; + void setupMigrationViewer(); not_null _widget; not_null _peer;