diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp index 6910a43a6..d2d304993 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.cpp @@ -314,7 +314,11 @@ ChatAdminRights AdminRightsForOwnershipTransfer(bool isGroup) { return result; } -Fn AboutGigagroupCallback(not_null channel) { +Fn AboutGigagroupCallback( + not_null channel, + not_null controller) { + const auto weak = base::make_weak(controller.get()); + const auto converting = std::make_shared(); const auto convertSure = [=] { if (*converting) { @@ -332,10 +336,11 @@ Fn AboutGigagroupCallback(not_null channel) { }).send(); }; const auto convertWarn = [=] { - if (*converting) { + const auto strongController = weak.get(); + if (*converting || !strongController) { return; } - Ui::show(Box([=](not_null box) { + strongController->show(Box([=](not_null box) { box->setTitle(tr::lng_gigagroup_warning_title()); box->addRow( object_ptr( @@ -348,10 +353,11 @@ Fn AboutGigagroupCallback(not_null channel) { }), Ui::LayerOption::KeepOther); }; return [=] { - if (*converting) { + const auto strongController = weak.get(); + if (*converting || !strongController) { return; } - Ui::show(Box([=](not_null box) { + strongController->show(Box([=](not_null box) { box->setTitle(tr::lng_gigagroup_convert_title()); const auto addFeature = [&](rpl::producer text) { using namespace rpl::mappers; @@ -607,7 +613,9 @@ void EditPeerPermissionsBox::addSuggestGigagroup( container, tr::lng_rights_gigagroup_convert(), rpl::single(QString()), - AboutGigagroupCallback(_peer->asChannel()), + AboutGigagroupCallback( + _peer->asChannel(), + _navigation->parentController()), st::peerPermissionsButton)); container->add( diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h index f4e23de39..38bbe1ec1 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_permissions_box.h @@ -16,6 +16,7 @@ class VerticalLayout; } // namespace Ui namespace Window { +class SessionController; class SessionNavigation; } // namespace Window @@ -50,7 +51,8 @@ private: }; [[nodiscard]] Fn AboutGigagroupCallback( - not_null channel); + not_null channel, + not_null controller); template struct EditFlagsControl { diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 4bcc7d696..bf8162baa 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -3935,7 +3935,7 @@ void HistoryWidget::checkSuggestToGigagroup() { st::infoAboutGigagroup)); box->addButton( tr::lng_gigagroup_suggest_more(), - AboutGigagroupCallback(group)); + AboutGigagroupCallback(group, controller())); box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); })); }