Simplified confirmed callback for ConfirmBox instances.

This commit is contained in:
23rd 2020-09-24 15:48:02 +03:00 committed by John Preston
parent 9f3af7234e
commit f81271d1fe
21 changed files with 89 additions and 144 deletions

View file

@ -244,7 +244,6 @@ private:
Fn<void()> _revokeCallback; Fn<void()> _revokeCallback;
mtpRequestId _revokeRequestId = 0; mtpRequestId _revokeRequestId = 0;
QPointer<ConfirmBox> _weakRevokeConfirmBox;
}; };
@ -1417,21 +1416,21 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
lt_group, lt_group,
pressed->name); pressed->name);
auto confirmText = tr::lng_channels_too_much_public_revoke(tr::now); auto confirmText = tr::lng_channels_too_much_public_revoke(tr::now);
_weakRevokeConfirmBox = Ui::show(Box<ConfirmBox>(text, confirmText, crl::guard(this, [this, pressed]() { auto callback = crl::guard(this, [=](Fn<void()> &&close) {
if (_revokeRequestId) return; if (_revokeRequestId) return;
_revokeRequestId = _api.request(MTPchannels_UpdateUsername( _revokeRequestId = _api.request(MTPchannels_UpdateUsername(
pressed->asChannel()->inputChannel, pressed->asChannel()->inputChannel,
MTP_string() MTP_string()
)).done([=](const MTPBool &result) { )).done([=, close = std::move(close)](const MTPBool &result) {
const auto callback = _revokeCallback; close();
if (_weakRevokeConfirmBox) { if (const auto callback = _revokeCallback) {
_weakRevokeConfirmBox->closeBox();
}
if (callback) {
callback(); callback();
} }
}).send(); }).send();
})), Ui::LayerOption::KeepOther); });
Ui::show(
Box<ConfirmBox>(text, confirmText, std::move(callback)),
Ui::LayerOption::KeepOther);
} }
} }

View file

@ -163,12 +163,9 @@ void BackgroundBox::prepare() {
} }
void BackgroundBox::removePaper(const Data::WallPaper &paper) { void BackgroundBox::removePaper(const Data::WallPaper &paper) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
const auto session = &_controller->session(); const auto session = &_controller->session();
const auto remove = [=, weak = Ui::MakeWeak(this)]{ const auto remove = [=, weak = Ui::MakeWeak(this)](Fn<void()> &&close) {
if (*box) { close();
(*box)->closeBox();
}
if (weak) { if (weak) {
weak->_inner->removePaper(paper); weak->_inner->removePaper(paper);
} }
@ -179,7 +176,7 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) {
paper.mtpSettings() paper.mtpSettings()
)).send(); )).send();
}; };
*box = Ui::show( Ui::show(
Box<ConfirmBox>( Box<ConfirmBox>(
tr::lng_background_sure_delete(tr::now), tr::lng_background_sure_delete(tr::now),
tr::lng_selected_delete(tr::now), tr::lng_selected_delete(tr::now),

View file

@ -1085,7 +1085,6 @@ void ProxiesBoxController::ShowApplyConfirmation(
proxy.password = fields.value(qsl("secret")); proxy.password = fields.value(qsl("secret"));
} }
if (proxy) { if (proxy) {
const auto box = std::make_shared<QPointer<ConfirmBox>>();
const auto text = tr::lng_sure_enable_socks( const auto text = tr::lng_sure_enable_socks(
tr::now, tr::now,
lt_server, lt_server,
@ -1095,7 +1094,7 @@ void ProxiesBoxController::ShowApplyConfirmation(
+ (proxy.type == Type::Mtproto + (proxy.type == Type::Mtproto
? "\n\n" + tr::lng_proxy_sponsor_warning(tr::now) ? "\n\n" + tr::lng_proxy_sponsor_warning(tr::now)
: QString()); : QString());
*box = Ui::show(Box<ConfirmBox>(text, tr::lng_sure_enable(tr::now), [=] { auto callback = [=](Fn<void()> &&close) {
auto &proxies = Global::RefProxiesList(); auto &proxies = Global::RefProxiesList();
if (!ranges::contains(proxies, proxy)) { if (!ranges::contains(proxies, proxy)) {
proxies.push_back(proxy); proxies.push_back(proxy);
@ -1104,10 +1103,14 @@ void ProxiesBoxController::ShowApplyConfirmation(
proxy, proxy,
ProxyData::Settings::Enabled); ProxyData::Settings::Enabled);
Local::writeSettings(); Local::writeSettings();
if (const auto strong = box->data()) { close();
strong->closeBox(); };
} Ui::show(
}), Ui::LayerOption::KeepOther); Box<ConfirmBox>(
text,
tr::lng_sure_enable(tr::now),
std::move(callback)),
Ui::LayerOption::KeepOther);
} else { } else {
Ui::show(Box<InformBox>( Ui::show(Box<InformBox>(
(proxy.status() == ProxyData::Status::Unsupported (proxy.status() == ProxyData::Status::Unsupported

View file

@ -602,14 +602,11 @@ void PasscodeBox::submitOnlyCheckCloudPassword(const QString &oldPassword) {
if (_cloudFields.turningOff && _cloudFields.notEmptyPassport) { if (_cloudFields.turningOff && _cloudFields.notEmptyPassport) {
Assert(!_cloudFields.customCheckCallback); Assert(!_cloudFields.customCheckCallback);
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto confirmed = [=](Fn<void()> &&close) {
const auto confirmed = [=] {
send(); send();
if (*box) { close();
(*box)->closeBox();
}
}; };
*box = getDelegate()->show(Box<ConfirmBox>( getDelegate()->show(Box<ConfirmBox>(
tr::lng_cloud_password_passport_losing(tr::now), tr::lng_cloud_password_passport_losing(tr::now),
tr::lng_continue(tr::now), tr::lng_continue(tr::now),
confirmed)); confirmed));
@ -809,20 +806,16 @@ void PasscodeBox::changeCloudPassword(
} }
void PasscodeBox::suggestSecretReset(const QString &newPassword) { void PasscodeBox::suggestSecretReset(const QString &newPassword) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); auto resetSecretAndSave = [=](Fn<void()> &&close) {
const auto resetSecretAndSave = [=] { checkPasswordHash([=, close = std::move(close)](
checkPasswordHash([=](const Core::CloudPasswordResult &check) { const Core::CloudPasswordResult &check) {
resetSecret(check, newPassword, [=] { resetSecret(check, newPassword, std::move(close));
if (*box) {
(*box)->closeBox();
}
});
}); });
}; };
*box = getDelegate()->show(Box<ConfirmBox>( getDelegate()->show(Box<ConfirmBox>(
Lang::Hard::PassportCorruptedChange(), Lang::Hard::PassportCorruptedChange(),
Lang::Hard::PassportCorruptedReset(), Lang::Hard::PassportCorruptedReset(),
[=] { resetSecretAndSave(); })); std::move(resetSecretAndSave)));
} }
void PasscodeBox::resetSecret( void PasscodeBox::resetSecret(
@ -1067,14 +1060,11 @@ void RecoverBox::submit() {
}).handleFloodErrors().send(); }).handleFloodErrors().send();
}); });
if (_notEmptyPassport) { if (_notEmptyPassport) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto confirmed = [=](Fn<void()> &&close) {
const auto confirmed = [=] {
send(); send();
if (*box) { close();
(*box)->closeBox();
}
}; };
*box = getDelegate()->show(Box<ConfirmBox>( getDelegate()->show(Box<ConfirmBox>(
tr::lng_cloud_password_passport_losing(tr::now), tr::lng_cloud_password_passport_losing(tr::now),
tr::lng_continue(tr::now), tr::lng_continue(tr::now),
confirmed)); confirmed));

View file

@ -146,15 +146,12 @@ void Controller::choose(not_null<ChannelData*> chat) {
Ui::Text::RichLangValue)); Ui::Text::RichLangValue));
} }
} }
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto sure = [=](Fn<void()> &&close) {
const auto sure = [=] { close();
if (*box) {
(*box)->closeBox();
}
const auto onstack = _callback; const auto onstack = _callback;
onstack(chat); onstack(chat);
}; };
*box = Ui::show( Ui::show(
Box<ConfirmBox>( Box<ConfirmBox>(
text, text,
tr::lng_manage_discussion_group_link(tr::now), tr::lng_manage_discussion_group_link(tr::now),
@ -178,18 +175,15 @@ void Controller::choose(not_null<ChatData*> chat) {
text.append(tr::lng_manage_discussion_group_warning( text.append(tr::lng_manage_discussion_group_warning(
tr::now, tr::now,
Ui::Text::RichLangValue)); Ui::Text::RichLangValue));
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto sure = [=](Fn<void()> &&close) {
const auto sure = [=] { close();
if (*box) {
(*box)->closeBox();
}
const auto done = [=](not_null<ChannelData*> chat) { const auto done = [=](not_null<ChannelData*> chat) {
const auto onstack = _callback; const auto onstack = _callback;
onstack(chat); onstack(chat);
}; };
chat->session().api().migrateChat(chat, crl::guard(this, done)); chat->session().api().migrateChat(chat, crl::guard(this, done));
}; };
*box = Ui::show( Ui::show(
Box<ConfirmBox>( Box<ConfirmBox>(
text, text,
tr::lng_manage_discussion_group_link(tr::now), tr::lng_manage_discussion_group_link(tr::now),

View file

@ -546,17 +546,14 @@ void Controller::revokeInviteLink() {
} }
void Controller::exportInviteLink(const QString &confirmation) { void Controller::exportInviteLink(const QString &confirmation) {
const auto boxPointer = std::make_shared<QPointer<ConfirmBox>>(); const auto callback = crl::guard(this, [=](Fn<void()> &&close) {
const auto callback = crl::guard(this, [=] { close();
if (const auto strong = *boxPointer) {
strong->closeBox();
}
_peer->session().api().exportInviteLink(_peer->migrateToOrMe()); _peer->session().api().exportInviteLink(_peer->migrateToOrMe());
}); });
auto box = Box<ConfirmBox>( auto box = Box<ConfirmBox>(
confirmation, confirmation,
std::move(callback)); std::move(callback));
*boxPointer = Ui::show(std::move(box), Ui::LayerOption::KeepOther); Ui::show(std::move(box), Ui::LayerOption::KeepOther);
} }
bool Controller::canEditInviteLink() const { bool Controller::canEditInviteLink() const {

View file

@ -380,12 +380,11 @@ bool HandleUnknown(
result.ventities().value_or_empty()) result.ventities().value_or_empty())
}; };
if (result.is_update_app()) { if (result.is_update_app()) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto callback = [=](Fn<void()> &&close) {
const auto callback = [=] {
Core::UpdateApplication(); Core::UpdateApplication();
if (*box) (*box)->closeBox(); close();
}; };
*box = Ui::show(Box<ConfirmBox>( Ui::show(Box<ConfirmBox>(
text, text,
tr::lng_menu_update(tr::now), tr::lng_menu_update(tr::now),
callback)); callback));

View file

@ -336,8 +336,7 @@ void ContactStatus::setupBlockHandler(not_null<UserData*> user) {
void ContactStatus::setupShareHandler(not_null<UserData*> user) { void ContactStatus::setupShareHandler(not_null<UserData*> user) {
_bar.entity()->shareClicks( _bar.entity()->shareClicks(
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto share = [=](Fn<void()> &&close) {
const auto share = [=] {
user->setSettings(0); user->setSettings(0);
user->session().api().request(MTPcontacts_AcceptContact( user->session().api().request(MTPcontacts_AcceptContact(
user->inputUser user->inputUser
@ -349,11 +348,9 @@ void ContactStatus::setupShareHandler(not_null<UserData*> user) {
lt_user, lt_user,
user->shortName())); user->shortName()));
}).send(); }).send();
if (*box) { close();
(*box)->closeBox();
}
}; };
*box = _controller->window().show(Box<ConfirmBox>( _controller->window().show(Box<ConfirmBox>(
tr::lng_new_contact_share_sure( tr::lng_new_contact_share_sure(
tr::now, tr::now,
lt_phone, lt_phone,
@ -387,11 +384,8 @@ void ContactStatus::setupReportHandler(not_null<PeerData*> peer) {
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
Expects(!peer->isUser()); Expects(!peer->isUser());
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto callback = crl::guard(&_bar, [=](Fn<void()> &&close) {
const auto callback = crl::guard(&_bar, [=] { close();
if (*box) {
(*box)->closeBox();
}
peer->session().api().request(MTPmessages_ReportSpam( peer->session().api().request(MTPmessages_ReportSpam(
peer->input peer->input

View file

@ -344,12 +344,11 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) {
_code->setFocus(); _code->setFocus();
return; return;
} else if (!getData()->pwdRequest) { } else if (!getData()->pwdRequest) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto callback = [=](Fn<void()> &&close) {
const auto callback = [=] {
Core::UpdateApplication(); Core::UpdateApplication();
if (*box) (*box)->closeBox(); close();
}; };
*box = Ui::show(Box<ConfirmBox>( Ui::show(Box<ConfirmBox>(
tr::lng_passport_app_out_of_date(tr::now), tr::lng_passport_app_out_of_date(tr::now),
tr::lng_menu_update(tr::now), tr::lng_menu_update(tr::now),
callback)); callback));

View file

@ -346,14 +346,11 @@ void PasswordCheckWidget::submit() {
}); });
if (_notEmptyPassport) { if (_notEmptyPassport) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto confirmed = [=](Fn<void()> &&close) {
const auto confirmed = [=] {
send(); send();
if (*box) { close();
(*box)->closeBox();
}
}; };
*box = Ui::show(Box<ConfirmBox>( Ui::show(Box<ConfirmBox>(
tr::lng_cloud_password_passport_losing(tr::now), tr::lng_cloud_password_passport_losing(tr::now),
tr::lng_continue(tr::now), tr::lng_continue(tr::now),
confirmed)); confirmed));

View file

@ -394,12 +394,11 @@ void QrWidget::sendCheckPasswordRequest() {
goReplace<QrWidget>(Animate::Forward); goReplace<QrWidget>(Animate::Forward);
return; return;
} else if (!getData()->pwdRequest) { } else if (!getData()->pwdRequest) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto callback = [=](Fn<void()> &&close) {
const auto callback = [=] {
Core::UpdateApplication(); Core::UpdateApplication();
if (*box) (*box)->closeBox(); close();
}; };
*box = Ui::show(Box<ConfirmBox>( Ui::show(Box<ConfirmBox>(
tr::lng_passport_app_out_of_date(tr::now), tr::lng_passport_app_out_of_date(tr::now),
tr::lng_menu_update(tr::now), tr::lng_menu_update(tr::now),
callback)); callback));

View file

@ -713,11 +713,10 @@ void PanelController::setupPassword() {
} }
void PanelController::cancelPasswordSubmit() { void PanelController::cancelPasswordSubmit() {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); show(Box<ConfirmBox>(
*box = show(Box<ConfirmBox>(
tr::lng_passport_stop_password_sure(tr::now), tr::lng_passport_stop_password_sure(tr::now),
tr::lng_passport_stop(tr::now), tr::lng_passport_stop(tr::now),
[=] { if (*box) (*box)->closeBox(); _form->cancelPassword(); })); [=](Fn<void()> &&close) { close(); _form->cancelPassword(); }));
} }
void PanelController::validateRecoveryEmail() { void PanelController::validateRecoveryEmail() {

View file

@ -514,11 +514,11 @@ void LastSeenPrivacyController::confirmSave(
FnMut<void()> saveCallback) { FnMut<void()> saveCallback) {
if (someAreDisallowed && !Core::App().settings().lastSeenWarningSeen()) { if (someAreDisallowed && !Core::App().settings().lastSeenWarningSeen()) {
const auto session = _session; const auto session = _session;
auto weakBox = std::make_shared<QPointer<ConfirmBox>>(); auto callback = [
auto callback = [=, saveCallback = std::move(saveCallback)]() mutable { =,
if (auto box = *weakBox) { saveCallback = std::move(saveCallback)
box->closeBox(); ](Fn<void()> &&close) mutable {
} close();
saveCallback(); saveCallback();
Core::App().settings().setLastSeenWarningSeen(true); Core::App().settings().setLastSeenWarningSeen(true);
Core::App().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
@ -528,7 +528,7 @@ void LastSeenPrivacyController::confirmSave(
tr::lng_continue(tr::now), tr::lng_continue(tr::now),
tr::lng_cancel(tr::now), tr::lng_cancel(tr::now),
std::move(callback)); std::move(callback));
*weakBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); Ui::show(std::move(box), Ui::LayerOption::KeepOther);
} else { } else {
saveCallback(); saveCallback();
} }

View file

@ -640,17 +640,14 @@ void RemoveCloudPassword(not_null<::Main::Session*> session) {
} }
object_ptr<Ui::BoxContent> CloudPasswordAppOutdatedBox() { object_ptr<Ui::BoxContent> CloudPasswordAppOutdatedBox() {
auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto callback = [=](Fn<void()> &&close) {
const auto callback = [=] {
Core::UpdateApplication(); Core::UpdateApplication();
if (*box) (*box)->closeBox(); close();
}; };
auto result = Box<ConfirmBox>( return Box<ConfirmBox>(
tr::lng_passport_app_out_of_date(tr::now), tr::lng_passport_app_out_of_date(tr::now),
tr::lng_menu_update(tr::now), tr::lng_menu_update(tr::now),
callback); callback);
*box = result.data();
return result;
} }
void AddPrivacyButton( void AddPrivacyButton(

View file

@ -1321,16 +1321,13 @@ void ToggleNightModeWithConfirmation(
if (Background()->nightModeChangeAllowed()) { if (Background()->nightModeChangeAllowed()) {
toggle(); toggle();
} else { } else {
const auto box = std::make_shared<QPointer<ConfirmBox>>(); const auto disableAndToggle = [=](Fn<void()> &&close) {
const auto disableAndToggle = [=] {
Core::App().settings().setSystemDarkModeEnabled(false); Core::App().settings().setSystemDarkModeEnabled(false);
Core::App().saveSettingsDelayed(); Core::App().saveSettingsDelayed();
toggle(); toggle();
if (*box) { close();
(*box)->closeBox();
}
}; };
*box = window->show(Box<ConfirmBox>( window->show(Box<ConfirmBox>(
tr::lng_settings_auto_night_warning(tr::now), tr::lng_settings_auto_night_warning(tr::now),
tr::lng_settings_auto_night_disable(tr::now), tr::lng_settings_auto_night_disable(tr::now),
disableAndToggle)); disableAndToggle));

View file

@ -892,15 +892,12 @@ void Editor::closeWithConfirmation() {
closeEditor(); closeEditor();
return; return;
} }
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto close = crl::guard(this, [=](Fn<void()> &&close) {
const auto close = crl::guard(this, [=] {
Background()->clearEditingTheme(ClearEditing::RevertChanges); Background()->clearEditingTheme(ClearEditing::RevertChanges);
closeEditor(); closeEditor();
if (*box) { close();
(*box)->closeBox();
}
}); });
*box = _window->show(Box<ConfirmBox>( _window->show(Box<ConfirmBox>(
tr::lng_theme_editor_sure_close(tr::now), tr::lng_theme_editor_sure_close(tr::now),
tr::lng_close(tr::now), tr::lng_close(tr::now),
close)); close));

View file

@ -599,11 +599,8 @@ void CloudList::showMenu(Element &element) {
} }
const auto id = cloud.id; const auto id = cloud.id;
_contextMenu->addAction(tr::lng_theme_delete(tr::now), [=] { _contextMenu->addAction(tr::lng_theme_delete(tr::now), [=] {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); const auto remove = [=](Fn<void()> &&close) {
const auto remove = [=] { close();
if (*box) {
(*box)->closeBox();
}
if (Background()->themeObject().cloud.id == id if (Background()->themeObject().cloud.id == id
|| id == kFakeCloudThemeId) { || id == kFakeCloudThemeId) {
if (Background()->editingTheme().has_value()) { if (Background()->editingTheme().has_value()) {
@ -618,7 +615,7 @@ void CloudList::showMenu(Element &element) {
_window->session().data().cloudThemes().remove(id); _window->session().data().cloudThemes().remove(id);
} }
}; };
*box = _window->window().show(Box<ConfirmBox>( _window->window().show(Box<ConfirmBox>(
tr::lng_theme_delete_sure(tr::now), tr::lng_theme_delete_sure(tr::now),
tr::lng_theme_delete(tr::now), tr::lng_theme_delete(tr::now),
remove)); remove));

View file

@ -177,7 +177,6 @@ void Controller::showTermsDecline() {
} }
void Controller::showTermsDelete() { void Controller::showTermsDelete() {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
const auto deleteByTerms = [=] { const auto deleteByTerms = [=] {
if (const auto session = account().maybeSession()) { if (const auto session = account().maybeSession()) {
session->termsDeleteNow(); session->termsDeleteNow();
@ -185,13 +184,12 @@ void Controller::showTermsDelete() {
Ui::hideLayer(); Ui::hideLayer();
} }
}; };
*box = Ui::show( Ui::show(
Box<ConfirmBox>( Box<ConfirmBox>(
tr::lng_terms_delete_warning(tr::now), tr::lng_terms_delete_warning(tr::now),
tr::lng_terms_delete_now(tr::now), tr::lng_terms_delete_now(tr::now),
st::attentionBoxButton, st::attentionBoxButton,
deleteByTerms, deleteByTerms),
[=] { if (*box) (*box)->closeBox(); }),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
} }

View file

@ -321,11 +321,10 @@ void FiltersMenu::showEditBox(FilterId id) {
} }
void FiltersMenu::showRemoveBox(FilterId id) { void FiltersMenu::showRemoveBox(FilterId id) {
const auto box = std::make_shared<QPointer<Ui::BoxContent>>(); _session->window().show(Box<ConfirmBox>(
*box = _session->window().show(Box<ConfirmBox>(
tr::lng_filters_remove_sure(tr::now), tr::lng_filters_remove_sure(tr::now),
tr::lng_filters_remove_yes(tr::now), tr::lng_filters_remove_yes(tr::now),
[=] { (*box)->closeBox(); remove(id); })); [=](Fn<void()> &&close) { close(); remove(id); }));
} }
void FiltersMenu::remove(FilterId id) { void FiltersMenu::remove(FilterId id) {

View file

@ -281,14 +281,11 @@ void MainMenu::AccountButton::contextMenuEvent(QContextMenuEvent *e) {
})); }));
_menu->addAction(tr::lng_settings_logout(tr::now), crl::guard(this, [=] { _menu->addAction(tr::lng_settings_logout(tr::now), crl::guard(this, [=] {
const auto session = _session; const auto session = _session;
const auto box = std::make_shared<QPointer<ConfirmBox>>(); const auto callback = [=](Fn<void()> &&close) {
const auto callback = [=] { close();
if (*box) {
(*box)->closeBox();
}
Core::App().logout(&session->account()); Core::App().logout(&session->account());
}; };
*box = Ui::show(Box<ConfirmBox>( Ui::show(Box<ConfirmBox>(
tr::lng_sure_logout(tr::now), tr::lng_sure_logout(tr::now),
tr::lng_settings_logout(tr::now), tr::lng_settings_logout(tr::now),
st::attentionBoxButton, st::attentionBoxButton,

View file

@ -1039,15 +1039,12 @@ QPointer<Ui::RpWidget> ShowSendNowMessagesBox(
}); });
return { nullptr }; return { nullptr };
} }
const auto box = std::make_shared<QPointer<Ui::BoxContent>>();
auto done = [ auto done = [
=, =,
list = std::move(items), list = std::move(items),
callback = std::move(successCallback) callback = std::move(successCallback)
]() mutable { ](Fn<void()> &&close) mutable {
if (*box) { close();
(*box)->closeBox();
}
auto ids = QVector<MTPint>(); auto ids = QVector<MTPint>();
for (const auto item : session->data().idsToItems(list)) { for (const auto item : session->data().idsToItems(list)) {
if (item->allowsSendNow()) { if (item->allowsSendNow()) {
@ -1067,10 +1064,9 @@ QPointer<Ui::RpWidget> ShowSendNowMessagesBox(
callback(); callback();
} }
}; };
*box = Ui::show( return Ui::show(
Box<ConfirmBox>(text, tr::lng_send_button(tr::now), std::move(done)), Box<ConfirmBox>(text, tr::lng_send_button(tr::now), std::move(done)),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther).data();
return box->data();
} }
void PeerMenuAddChannelMembers( void PeerMenuAddChannelMembers(