From bdb2a5f2771dbd3aa9402f79361ab0b89826ba56 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 3 Mar 2022 10:50:48 +0300 Subject: [PATCH] Removed Ui::show from EditAdminBox and EditRestrictedBox. --- .../boxes/peers/edit_participant_box.cpp | 56 ++++++++++--------- .../boxes/peers/edit_participant_box.h | 2 + 2 files changed, 33 insertions(+), 25 deletions(-) diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 6a9c81d5bc..20598ee306 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -204,6 +204,7 @@ EditAdminBox::EditAdminBox( peer, user, (rights.flags != 0)) +, _show(this) , _oldRights(rights) , _oldRank(rank) { } @@ -534,15 +535,19 @@ void EditAdminBox::sendTransferRequestFrom( channel->inputChannel, user->inputUser, result.result - )).done([=](const MTPUpdates &result) { + )).done([=, toastParent = _show.toastParent()](const MTPUpdates &result) { api->applyUpdates(result); - Ui::Toast::Show((channel->isBroadcast() - ? tr::lng_rights_transfer_done_channel - : tr::lng_rights_transfer_done_group)( - tr::now, - lt_user, - user->shortName())); - Ui::hideLayer(); + Ui::Toast::Show( + toastParent, + (channel->isBroadcast() + ? tr::lng_rights_transfer_done_channel + : tr::lng_rights_transfer_done_group)( + tr::now, + lt_user, + user->shortName())); + if (weak) { + _show.hideLayer(); + } }).fail(crl::guard(this, [=](const MTP::Error &error) { if (weak) { _transferRequestId = 0; @@ -604,6 +609,7 @@ EditRestrictedBox::EditRestrictedBox( bool hasAdminRights, ChatRestrictionsInfo rights) : EditParticipantBox(nullptr, peer, user, hasAdminRights) +, _show(this) , _oldRights(rights) { } @@ -701,23 +707,23 @@ void EditRestrictedBox::showRestrictUntil() { ? tomorrow : base::unixtime::parse(getRealUntilValue()).date(); auto month = highlighted; - _restrictUntilBox = Ui::show( - Box(Ui::CalendarBoxArgs{ - .month = month, - .highlighted = highlighted, - .callback = [=](const QDate &date) { - setRestrictUntil( - static_cast(date.startOfDay().toSecsSinceEpoch())); - }, - .finalize = [=](not_null box) { - box->addLeftButton( - tr::lng_rights_chat_banned_forever(), - [=] { setRestrictUntil(0); }); - }, - .minDate = tomorrow, - .maxDate = QDate::currentDate().addDays(kMaxRestrictDelayDays), - }), - Ui::LayerOption::KeepOther); + auto box = Box(Ui::CalendarBoxArgs{ + .month = month, + .highlighted = highlighted, + .callback = [=](const QDate &date) { + setRestrictUntil( + static_cast(date.startOfDay().toSecsSinceEpoch())); + }, + .finalize = [=](not_null box) { + box->addLeftButton( + tr::lng_rights_chat_banned_forever(), + [=] { setRestrictUntil(0); }); + }, + .minDate = tomorrow, + .maxDate = QDate::currentDate().addDays(kMaxRestrictDelayDays), + }); + _restrictUntilBox = Ui::MakeWeak(box.data()); + _show.showBox(std::move(box)); } void EditRestrictedBox::setRestrictUntil(TimeId until) { diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h index 54f83210f1..61c89a377d 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.h +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.h @@ -103,6 +103,7 @@ private: bool canTransferOwnership() const; not_null*> setupTransferButton(bool isGroup); + const Ui::BoxShow _show; const ChatAdminRightsInfo _oldRights; const QString _oldRank; Fn _saveCallback;