Removed Ui::show from EditAdminBox and EditRestrictedBox.

This commit is contained in:
23rd 2022-03-03 10:50:48 +03:00
parent 1f8f462461
commit bdb2a5f277
2 changed files with 33 additions and 25 deletions

View file

@ -204,6 +204,7 @@ EditAdminBox::EditAdminBox(
peer, peer,
user, user,
(rights.flags != 0)) (rights.flags != 0))
, _show(this)
, _oldRights(rights) , _oldRights(rights)
, _oldRank(rank) { , _oldRank(rank) {
} }
@ -534,15 +535,19 @@ void EditAdminBox::sendTransferRequestFrom(
channel->inputChannel, channel->inputChannel,
user->inputUser, user->inputUser,
result.result result.result
)).done([=](const MTPUpdates &result) { )).done([=, toastParent = _show.toastParent()](const MTPUpdates &result) {
api->applyUpdates(result); api->applyUpdates(result);
Ui::Toast::Show((channel->isBroadcast() Ui::Toast::Show(
toastParent,
(channel->isBroadcast()
? tr::lng_rights_transfer_done_channel ? tr::lng_rights_transfer_done_channel
: tr::lng_rights_transfer_done_group)( : tr::lng_rights_transfer_done_group)(
tr::now, tr::now,
lt_user, lt_user,
user->shortName())); user->shortName()));
Ui::hideLayer(); if (weak) {
_show.hideLayer();
}
}).fail(crl::guard(this, [=](const MTP::Error &error) { }).fail(crl::guard(this, [=](const MTP::Error &error) {
if (weak) { if (weak) {
_transferRequestId = 0; _transferRequestId = 0;
@ -604,6 +609,7 @@ EditRestrictedBox::EditRestrictedBox(
bool hasAdminRights, bool hasAdminRights,
ChatRestrictionsInfo rights) ChatRestrictionsInfo rights)
: EditParticipantBox(nullptr, peer, user, hasAdminRights) : EditParticipantBox(nullptr, peer, user, hasAdminRights)
, _show(this)
, _oldRights(rights) { , _oldRights(rights) {
} }
@ -701,8 +707,7 @@ void EditRestrictedBox::showRestrictUntil() {
? tomorrow ? tomorrow
: base::unixtime::parse(getRealUntilValue()).date(); : base::unixtime::parse(getRealUntilValue()).date();
auto month = highlighted; auto month = highlighted;
_restrictUntilBox = Ui::show( auto box = Box<Ui::CalendarBox>(Ui::CalendarBoxArgs{
Box<Ui::CalendarBox>(Ui::CalendarBoxArgs{
.month = month, .month = month,
.highlighted = highlighted, .highlighted = highlighted,
.callback = [=](const QDate &date) { .callback = [=](const QDate &date) {
@ -716,8 +721,9 @@ void EditRestrictedBox::showRestrictUntil() {
}, },
.minDate = tomorrow, .minDate = tomorrow,
.maxDate = QDate::currentDate().addDays(kMaxRestrictDelayDays), .maxDate = QDate::currentDate().addDays(kMaxRestrictDelayDays),
}), });
Ui::LayerOption::KeepOther); _restrictUntilBox = Ui::MakeWeak(box.data());
_show.showBox(std::move(box));
} }
void EditRestrictedBox::setRestrictUntil(TimeId until) { void EditRestrictedBox::setRestrictUntil(TimeId until) {

View file

@ -103,6 +103,7 @@ private:
bool canTransferOwnership() const; bool canTransferOwnership() const;
not_null<Ui::SlideWrap<Ui::RpWidget>*> setupTransferButton(bool isGroup); not_null<Ui::SlideWrap<Ui::RpWidget>*> setupTransferButton(bool isGroup);
const Ui::BoxShow _show;
const ChatAdminRightsInfo _oldRights; const ChatAdminRightsInfo _oldRights;
const QString _oldRank; const QString _oldRank;
Fn<void( Fn<void(
@ -149,6 +150,7 @@ private:
void createUntilVariants(); void createUntilVariants();
TimeId getRealUntilValue() const; TimeId getRealUntilValue() const;
const Ui::BoxShow _show;
const ChatRestrictionsInfo _oldRights; const ChatRestrictionsInfo _oldRights;
TimeId _until = 0; TimeId _until = 0;
Fn<void(ChatRestrictionsInfo, ChatRestrictionsInfo)> _saveCallback; Fn<void(ChatRestrictionsInfo, ChatRestrictionsInfo)> _saveCallback;