Provided window controller to box of converting channel to gigagroup.

This commit is contained in:
23rd 2022-02-20 13:42:12 +03:00
parent 6bcca6c94e
commit bc6d69319c
3 changed files with 18 additions and 8 deletions

View file

@ -314,7 +314,11 @@ ChatAdminRights AdminRightsForOwnershipTransfer(bool isGroup) {
return result;
}
Fn<void()> AboutGigagroupCallback(not_null<ChannelData*> channel) {
Fn<void()> AboutGigagroupCallback(
not_null<ChannelData*> channel,
not_null<Window::SessionController*> controller) {
const auto weak = base::make_weak(controller.get());
const auto converting = std::make_shared<bool>();
const auto convertSure = [=] {
if (*converting) {
@ -332,10 +336,11 @@ Fn<void()> AboutGigagroupCallback(not_null<ChannelData*> channel) {
}).send();
};
const auto convertWarn = [=] {
if (*converting) {
const auto strongController = weak.get();
if (*converting || !strongController) {
return;
}
Ui::show(Box([=](not_null<Ui::GenericBox*> box) {
strongController->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(tr::lng_gigagroup_warning_title());
box->addRow(
object_ptr<Ui::FlatLabel>(
@ -348,10 +353,11 @@ Fn<void()> AboutGigagroupCallback(not_null<ChannelData*> channel) {
}), Ui::LayerOption::KeepOther);
};
return [=] {
if (*converting) {
const auto strongController = weak.get();
if (*converting || !strongController) {
return;
}
Ui::show(Box([=](not_null<Ui::GenericBox*> box) {
strongController->show(Box([=](not_null<Ui::GenericBox*> box) {
box->setTitle(tr::lng_gigagroup_convert_title());
const auto addFeature = [&](rpl::producer<QString> 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(

View file

@ -16,6 +16,7 @@ class VerticalLayout;
} // namespace Ui
namespace Window {
class SessionController;
class SessionNavigation;
} // namespace Window
@ -50,7 +51,8 @@ private:
};
[[nodiscard]] Fn<void()> AboutGigagroupCallback(
not_null<ChannelData*> channel);
not_null<ChannelData*> channel,
not_null<Window::SessionController*> controller);
template <typename Flags>
struct EditFlagsControl {

View file

@ -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(); });
}));
}