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,
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::CalendarBox>(Ui::CalendarBoxArgs{
.month = month,
.highlighted = highlighted,
.callback = [=](const QDate &date) {
setRestrictUntil(
static_cast<int>(date.startOfDay().toSecsSinceEpoch()));
},
.finalize = [=](not_null<Ui::CalendarBox*> 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::CalendarBox>(Ui::CalendarBoxArgs{
.month = month,
.highlighted = highlighted,
.callback = [=](const QDate &date) {
setRestrictUntil(
static_cast<int>(date.startOfDay().toSecsSinceEpoch()));
},
.finalize = [=](not_null<Ui::CalendarBox*> 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) {

View File

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