From f81271d1fe81555b4cab00d25517c5dfa783a97b Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 24 Sep 2020 15:48:02 +0300 Subject: [PATCH] Simplified confirmed callback for ConfirmBox instances. --- .../SourceFiles/boxes/add_contact_box.cpp | 17 +++++----- Telegram/SourceFiles/boxes/background_box.cpp | 9 ++--- Telegram/SourceFiles/boxes/connection_box.cpp | 15 ++++---- Telegram/SourceFiles/boxes/passcode_box.cpp | 34 +++++++------------ .../boxes/peers/edit_linked_chat_box.cpp | 18 ++++------ .../boxes/peers/edit_peer_type_box.cpp | 9 ++--- .../SourceFiles/core/local_url_handlers.cpp | 7 ++-- .../view/history_view_contact_status.cpp | 16 +++------ Telegram/SourceFiles/intro/intro_code.cpp | 7 ++-- .../intro/intro_password_check.cpp | 9 ++--- Telegram/SourceFiles/intro/intro_qr.cpp | 7 ++-- .../passport/passport_panel_controller.cpp | 5 ++- .../settings/settings_privacy_controllers.cpp | 12 +++---- .../settings/settings_privacy_security.cpp | 9 ++--- .../window/themes/window_theme.cpp | 9 ++--- .../window/themes/window_theme_editor.cpp | 9 ++--- .../themes/window_themes_cloud_list.cpp | 9 ++--- .../SourceFiles/window/window_controller.cpp | 6 ++-- .../window/window_filters_menu.cpp | 5 ++- .../SourceFiles/window/window_main_menu.cpp | 9 ++--- .../SourceFiles/window/window_peer_menu.cpp | 12 +++---- 21 files changed, 89 insertions(+), 144 deletions(-) diff --git a/Telegram/SourceFiles/boxes/add_contact_box.cpp b/Telegram/SourceFiles/boxes/add_contact_box.cpp index 9997e77de..aab5438ba 100644 --- a/Telegram/SourceFiles/boxes/add_contact_box.cpp +++ b/Telegram/SourceFiles/boxes/add_contact_box.cpp @@ -244,7 +244,6 @@ private: Fn _revokeCallback; mtpRequestId _revokeRequestId = 0; - QPointer _weakRevokeConfirmBox; }; @@ -1417,21 +1416,21 @@ void RevokePublicLinkBox::Inner::mouseReleaseEvent(QMouseEvent *e) { lt_group, pressed->name); auto confirmText = tr::lng_channels_too_much_public_revoke(tr::now); - _weakRevokeConfirmBox = Ui::show(Box(text, confirmText, crl::guard(this, [this, pressed]() { + auto callback = crl::guard(this, [=](Fn &&close) { if (_revokeRequestId) return; _revokeRequestId = _api.request(MTPchannels_UpdateUsername( pressed->asChannel()->inputChannel, MTP_string() - )).done([=](const MTPBool &result) { - const auto callback = _revokeCallback; - if (_weakRevokeConfirmBox) { - _weakRevokeConfirmBox->closeBox(); - } - if (callback) { + )).done([=, close = std::move(close)](const MTPBool &result) { + close(); + if (const auto callback = _revokeCallback) { callback(); } }).send(); - })), Ui::LayerOption::KeepOther); + }); + Ui::show( + Box(text, confirmText, std::move(callback)), + Ui::LayerOption::KeepOther); } } diff --git a/Telegram/SourceFiles/boxes/background_box.cpp b/Telegram/SourceFiles/boxes/background_box.cpp index 69426c68d..3de10653c 100644 --- a/Telegram/SourceFiles/boxes/background_box.cpp +++ b/Telegram/SourceFiles/boxes/background_box.cpp @@ -163,12 +163,9 @@ void BackgroundBox::prepare() { } void BackgroundBox::removePaper(const Data::WallPaper &paper) { - const auto box = std::make_shared>(); const auto session = &_controller->session(); - const auto remove = [=, weak = Ui::MakeWeak(this)]{ - if (*box) { - (*box)->closeBox(); - } + const auto remove = [=, weak = Ui::MakeWeak(this)](Fn &&close) { + close(); if (weak) { weak->_inner->removePaper(paper); } @@ -179,7 +176,7 @@ void BackgroundBox::removePaper(const Data::WallPaper &paper) { paper.mtpSettings() )).send(); }; - *box = Ui::show( + Ui::show( Box( tr::lng_background_sure_delete(tr::now), tr::lng_selected_delete(tr::now), diff --git a/Telegram/SourceFiles/boxes/connection_box.cpp b/Telegram/SourceFiles/boxes/connection_box.cpp index 123341aa3..638251871 100644 --- a/Telegram/SourceFiles/boxes/connection_box.cpp +++ b/Telegram/SourceFiles/boxes/connection_box.cpp @@ -1085,7 +1085,6 @@ void ProxiesBoxController::ShowApplyConfirmation( proxy.password = fields.value(qsl("secret")); } if (proxy) { - const auto box = std::make_shared>(); const auto text = tr::lng_sure_enable_socks( tr::now, lt_server, @@ -1095,7 +1094,7 @@ void ProxiesBoxController::ShowApplyConfirmation( + (proxy.type == Type::Mtproto ? "\n\n" + tr::lng_proxy_sponsor_warning(tr::now) : QString()); - *box = Ui::show(Box(text, tr::lng_sure_enable(tr::now), [=] { + auto callback = [=](Fn &&close) { auto &proxies = Global::RefProxiesList(); if (!ranges::contains(proxies, proxy)) { proxies.push_back(proxy); @@ -1104,10 +1103,14 @@ void ProxiesBoxController::ShowApplyConfirmation( proxy, ProxyData::Settings::Enabled); Local::writeSettings(); - if (const auto strong = box->data()) { - strong->closeBox(); - } - }), Ui::LayerOption::KeepOther); + close(); + }; + Ui::show( + Box( + text, + tr::lng_sure_enable(tr::now), + std::move(callback)), + Ui::LayerOption::KeepOther); } else { Ui::show(Box( (proxy.status() == ProxyData::Status::Unsupported diff --git a/Telegram/SourceFiles/boxes/passcode_box.cpp b/Telegram/SourceFiles/boxes/passcode_box.cpp index d6688ce7a..475e9bac5 100644 --- a/Telegram/SourceFiles/boxes/passcode_box.cpp +++ b/Telegram/SourceFiles/boxes/passcode_box.cpp @@ -602,14 +602,11 @@ void PasscodeBox::submitOnlyCheckCloudPassword(const QString &oldPassword) { if (_cloudFields.turningOff && _cloudFields.notEmptyPassport) { Assert(!_cloudFields.customCheckCallback); - const auto box = std::make_shared>(); - const auto confirmed = [=] { + const auto confirmed = [=](Fn &&close) { send(); - if (*box) { - (*box)->closeBox(); - } + close(); }; - *box = getDelegate()->show(Box( + getDelegate()->show(Box( tr::lng_cloud_password_passport_losing(tr::now), tr::lng_continue(tr::now), confirmed)); @@ -809,20 +806,16 @@ void PasscodeBox::changeCloudPassword( } void PasscodeBox::suggestSecretReset(const QString &newPassword) { - const auto box = std::make_shared>(); - const auto resetSecretAndSave = [=] { - checkPasswordHash([=](const Core::CloudPasswordResult &check) { - resetSecret(check, newPassword, [=] { - if (*box) { - (*box)->closeBox(); - } - }); + auto resetSecretAndSave = [=](Fn &&close) { + checkPasswordHash([=, close = std::move(close)]( + const Core::CloudPasswordResult &check) { + resetSecret(check, newPassword, std::move(close)); }); }; - *box = getDelegate()->show(Box( + getDelegate()->show(Box( Lang::Hard::PassportCorruptedChange(), Lang::Hard::PassportCorruptedReset(), - [=] { resetSecretAndSave(); })); + std::move(resetSecretAndSave))); } void PasscodeBox::resetSecret( @@ -1067,14 +1060,11 @@ void RecoverBox::submit() { }).handleFloodErrors().send(); }); if (_notEmptyPassport) { - const auto box = std::make_shared>(); - const auto confirmed = [=] { + const auto confirmed = [=](Fn &&close) { send(); - if (*box) { - (*box)->closeBox(); - } + close(); }; - *box = getDelegate()->show(Box( + getDelegate()->show(Box( tr::lng_cloud_password_passport_losing(tr::now), tr::lng_continue(tr::now), confirmed)); diff --git a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp index cc55265a8..2495d2017 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_linked_chat_box.cpp @@ -146,15 +146,12 @@ void Controller::choose(not_null chat) { Ui::Text::RichLangValue)); } } - const auto box = std::make_shared>(); - const auto sure = [=] { - if (*box) { - (*box)->closeBox(); - } + const auto sure = [=](Fn &&close) { + close(); const auto onstack = _callback; onstack(chat); }; - *box = Ui::show( + Ui::show( Box( text, tr::lng_manage_discussion_group_link(tr::now), @@ -178,18 +175,15 @@ void Controller::choose(not_null chat) { text.append(tr::lng_manage_discussion_group_warning( tr::now, Ui::Text::RichLangValue)); - const auto box = std::make_shared>(); - const auto sure = [=] { - if (*box) { - (*box)->closeBox(); - } + const auto sure = [=](Fn &&close) { + close(); const auto done = [=](not_null chat) { const auto onstack = _callback; onstack(chat); }; chat->session().api().migrateChat(chat, crl::guard(this, done)); }; - *box = Ui::show( + Ui::show( Box( text, tr::lng_manage_discussion_group_link(tr::now), diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index 5d7d71024..386d1c36e 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -546,17 +546,14 @@ void Controller::revokeInviteLink() { } void Controller::exportInviteLink(const QString &confirmation) { - const auto boxPointer = std::make_shared>(); - const auto callback = crl::guard(this, [=] { - if (const auto strong = *boxPointer) { - strong->closeBox(); - } + const auto callback = crl::guard(this, [=](Fn &&close) { + close(); _peer->session().api().exportInviteLink(_peer->migrateToOrMe()); }); auto box = Box( confirmation, std::move(callback)); - *boxPointer = Ui::show(std::move(box), Ui::LayerOption::KeepOther); + Ui::show(std::move(box), Ui::LayerOption::KeepOther); } bool Controller::canEditInviteLink() const { diff --git a/Telegram/SourceFiles/core/local_url_handlers.cpp b/Telegram/SourceFiles/core/local_url_handlers.cpp index 0c709a8d0..cda4d9141 100644 --- a/Telegram/SourceFiles/core/local_url_handlers.cpp +++ b/Telegram/SourceFiles/core/local_url_handlers.cpp @@ -380,12 +380,11 @@ bool HandleUnknown( result.ventities().value_or_empty()) }; if (result.is_update_app()) { - const auto box = std::make_shared>(); - const auto callback = [=] { + const auto callback = [=](Fn &&close) { Core::UpdateApplication(); - if (*box) (*box)->closeBox(); + close(); }; - *box = Ui::show(Box( + Ui::show(Box( text, tr::lng_menu_update(tr::now), callback)); diff --git a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp index 83cdd774c..84555f5ff 100644 --- a/Telegram/SourceFiles/history/view/history_view_contact_status.cpp +++ b/Telegram/SourceFiles/history/view/history_view_contact_status.cpp @@ -336,8 +336,7 @@ void ContactStatus::setupBlockHandler(not_null user) { void ContactStatus::setupShareHandler(not_null user) { _bar.entity()->shareClicks( ) | rpl::start_with_next([=] { - const auto box = std::make_shared>(); - const auto share = [=] { + const auto share = [=](Fn &&close) { user->setSettings(0); user->session().api().request(MTPcontacts_AcceptContact( user->inputUser @@ -349,11 +348,9 @@ void ContactStatus::setupShareHandler(not_null user) { lt_user, user->shortName())); }).send(); - if (*box) { - (*box)->closeBox(); - } + close(); }; - *box = _controller->window().show(Box( + _controller->window().show(Box( tr::lng_new_contact_share_sure( tr::now, lt_phone, @@ -387,11 +384,8 @@ void ContactStatus::setupReportHandler(not_null peer) { ) | rpl::start_with_next([=] { Expects(!peer->isUser()); - const auto box = std::make_shared>(); - const auto callback = crl::guard(&_bar, [=] { - if (*box) { - (*box)->closeBox(); - } + const auto callback = crl::guard(&_bar, [=](Fn &&close) { + close(); peer->session().api().request(MTPmessages_ReportSpam( peer->input diff --git a/Telegram/SourceFiles/intro/intro_code.cpp b/Telegram/SourceFiles/intro/intro_code.cpp index 45464513f..3efe3c9a1 100644 --- a/Telegram/SourceFiles/intro/intro_code.cpp +++ b/Telegram/SourceFiles/intro/intro_code.cpp @@ -344,12 +344,11 @@ void CodeWidget::gotPassword(const MTPaccount_Password &result) { _code->setFocus(); return; } else if (!getData()->pwdRequest) { - const auto box = std::make_shared>(); - const auto callback = [=] { + const auto callback = [=](Fn &&close) { Core::UpdateApplication(); - if (*box) (*box)->closeBox(); + close(); }; - *box = Ui::show(Box( + Ui::show(Box( tr::lng_passport_app_out_of_date(tr::now), tr::lng_menu_update(tr::now), callback)); diff --git a/Telegram/SourceFiles/intro/intro_password_check.cpp b/Telegram/SourceFiles/intro/intro_password_check.cpp index d1a3ce50c..17b009c46 100644 --- a/Telegram/SourceFiles/intro/intro_password_check.cpp +++ b/Telegram/SourceFiles/intro/intro_password_check.cpp @@ -346,14 +346,11 @@ void PasswordCheckWidget::submit() { }); if (_notEmptyPassport) { - const auto box = std::make_shared>(); - const auto confirmed = [=] { + const auto confirmed = [=](Fn &&close) { send(); - if (*box) { - (*box)->closeBox(); - } + close(); }; - *box = Ui::show(Box( + Ui::show(Box( tr::lng_cloud_password_passport_losing(tr::now), tr::lng_continue(tr::now), confirmed)); diff --git a/Telegram/SourceFiles/intro/intro_qr.cpp b/Telegram/SourceFiles/intro/intro_qr.cpp index 99d168b29..380889263 100644 --- a/Telegram/SourceFiles/intro/intro_qr.cpp +++ b/Telegram/SourceFiles/intro/intro_qr.cpp @@ -394,12 +394,11 @@ void QrWidget::sendCheckPasswordRequest() { goReplace(Animate::Forward); return; } else if (!getData()->pwdRequest) { - const auto box = std::make_shared>(); - const auto callback = [=] { + const auto callback = [=](Fn &&close) { Core::UpdateApplication(); - if (*box) (*box)->closeBox(); + close(); }; - *box = Ui::show(Box( + Ui::show(Box( tr::lng_passport_app_out_of_date(tr::now), tr::lng_menu_update(tr::now), callback)); diff --git a/Telegram/SourceFiles/passport/passport_panel_controller.cpp b/Telegram/SourceFiles/passport/passport_panel_controller.cpp index 35ff2ea64..e98bf1646 100644 --- a/Telegram/SourceFiles/passport/passport_panel_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_panel_controller.cpp @@ -713,11 +713,10 @@ void PanelController::setupPassword() { } void PanelController::cancelPasswordSubmit() { - const auto box = std::make_shared>(); - *box = show(Box( + show(Box( tr::lng_passport_stop_password_sure(tr::now), tr::lng_passport_stop(tr::now), - [=] { if (*box) (*box)->closeBox(); _form->cancelPassword(); })); + [=](Fn &&close) { close(); _form->cancelPassword(); })); } void PanelController::validateRecoveryEmail() { diff --git a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp index c6ee41750..bc66f2c60 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_controllers.cpp @@ -514,11 +514,11 @@ void LastSeenPrivacyController::confirmSave( FnMut saveCallback) { if (someAreDisallowed && !Core::App().settings().lastSeenWarningSeen()) { const auto session = _session; - auto weakBox = std::make_shared>(); - auto callback = [=, saveCallback = std::move(saveCallback)]() mutable { - if (auto box = *weakBox) { - box->closeBox(); - } + auto callback = [ + =, + saveCallback = std::move(saveCallback) + ](Fn &&close) mutable { + close(); saveCallback(); Core::App().settings().setLastSeenWarningSeen(true); Core::App().saveSettingsDelayed(); @@ -528,7 +528,7 @@ void LastSeenPrivacyController::confirmSave( tr::lng_continue(tr::now), tr::lng_cancel(tr::now), std::move(callback)); - *weakBox = Ui::show(std::move(box), Ui::LayerOption::KeepOther); + Ui::show(std::move(box), Ui::LayerOption::KeepOther); } else { saveCallback(); } diff --git a/Telegram/SourceFiles/settings/settings_privacy_security.cpp b/Telegram/SourceFiles/settings/settings_privacy_security.cpp index f04f49af1..12292f573 100644 --- a/Telegram/SourceFiles/settings/settings_privacy_security.cpp +++ b/Telegram/SourceFiles/settings/settings_privacy_security.cpp @@ -640,17 +640,14 @@ void RemoveCloudPassword(not_null<::Main::Session*> session) { } object_ptr CloudPasswordAppOutdatedBox() { - auto box = std::make_shared>(); - const auto callback = [=] { + const auto callback = [=](Fn &&close) { Core::UpdateApplication(); - if (*box) (*box)->closeBox(); + close(); }; - auto result = Box( + return Box( tr::lng_passport_app_out_of_date(tr::now), tr::lng_menu_update(tr::now), callback); - *box = result.data(); - return result; } void AddPrivacyButton( diff --git a/Telegram/SourceFiles/window/themes/window_theme.cpp b/Telegram/SourceFiles/window/themes/window_theme.cpp index 5f8015059..67391766f 100644 --- a/Telegram/SourceFiles/window/themes/window_theme.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme.cpp @@ -1321,16 +1321,13 @@ void ToggleNightModeWithConfirmation( if (Background()->nightModeChangeAllowed()) { toggle(); } else { - const auto box = std::make_shared>(); - const auto disableAndToggle = [=] { + const auto disableAndToggle = [=](Fn &&close) { Core::App().settings().setSystemDarkModeEnabled(false); Core::App().saveSettingsDelayed(); toggle(); - if (*box) { - (*box)->closeBox(); - } + close(); }; - *box = window->show(Box( + window->show(Box( tr::lng_settings_auto_night_warning(tr::now), tr::lng_settings_auto_night_disable(tr::now), disableAndToggle)); diff --git a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp index efeb5cf09..ef6e3d3a0 100644 --- a/Telegram/SourceFiles/window/themes/window_theme_editor.cpp +++ b/Telegram/SourceFiles/window/themes/window_theme_editor.cpp @@ -892,15 +892,12 @@ void Editor::closeWithConfirmation() { closeEditor(); return; } - const auto box = std::make_shared>(); - const auto close = crl::guard(this, [=] { + const auto close = crl::guard(this, [=](Fn &&close) { Background()->clearEditingTheme(ClearEditing::RevertChanges); closeEditor(); - if (*box) { - (*box)->closeBox(); - } + close(); }); - *box = _window->show(Box( + _window->show(Box( tr::lng_theme_editor_sure_close(tr::now), tr::lng_close(tr::now), close)); diff --git a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp index a620abe79..ab355c0e0 100644 --- a/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp +++ b/Telegram/SourceFiles/window/themes/window_themes_cloud_list.cpp @@ -599,11 +599,8 @@ void CloudList::showMenu(Element &element) { } const auto id = cloud.id; _contextMenu->addAction(tr::lng_theme_delete(tr::now), [=] { - const auto box = std::make_shared>(); - const auto remove = [=] { - if (*box) { - (*box)->closeBox(); - } + const auto remove = [=](Fn &&close) { + close(); if (Background()->themeObject().cloud.id == id || id == kFakeCloudThemeId) { if (Background()->editingTheme().has_value()) { @@ -618,7 +615,7 @@ void CloudList::showMenu(Element &element) { _window->session().data().cloudThemes().remove(id); } }; - *box = _window->window().show(Box( + _window->window().show(Box( tr::lng_theme_delete_sure(tr::now), tr::lng_theme_delete(tr::now), remove)); diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index 41eaf073b..fbb53d508 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -177,7 +177,6 @@ void Controller::showTermsDecline() { } void Controller::showTermsDelete() { - const auto box = std::make_shared>(); const auto deleteByTerms = [=] { if (const auto session = account().maybeSession()) { session->termsDeleteNow(); @@ -185,13 +184,12 @@ void Controller::showTermsDelete() { Ui::hideLayer(); } }; - *box = Ui::show( + Ui::show( Box( tr::lng_terms_delete_warning(tr::now), tr::lng_terms_delete_now(tr::now), st::attentionBoxButton, - deleteByTerms, - [=] { if (*box) (*box)->closeBox(); }), + deleteByTerms), Ui::LayerOption::KeepOther); } diff --git a/Telegram/SourceFiles/window/window_filters_menu.cpp b/Telegram/SourceFiles/window/window_filters_menu.cpp index a2a863965..d12ddc510 100644 --- a/Telegram/SourceFiles/window/window_filters_menu.cpp +++ b/Telegram/SourceFiles/window/window_filters_menu.cpp @@ -321,11 +321,10 @@ void FiltersMenu::showEditBox(FilterId id) { } void FiltersMenu::showRemoveBox(FilterId id) { - const auto box = std::make_shared>(); - *box = _session->window().show(Box( + _session->window().show(Box( tr::lng_filters_remove_sure(tr::now), tr::lng_filters_remove_yes(tr::now), - [=] { (*box)->closeBox(); remove(id); })); + [=](Fn &&close) { close(); remove(id); })); } void FiltersMenu::remove(FilterId id) { diff --git a/Telegram/SourceFiles/window/window_main_menu.cpp b/Telegram/SourceFiles/window/window_main_menu.cpp index 5836cf69f..f8800de98 100644 --- a/Telegram/SourceFiles/window/window_main_menu.cpp +++ b/Telegram/SourceFiles/window/window_main_menu.cpp @@ -281,14 +281,11 @@ void MainMenu::AccountButton::contextMenuEvent(QContextMenuEvent *e) { })); _menu->addAction(tr::lng_settings_logout(tr::now), crl::guard(this, [=] { const auto session = _session; - const auto box = std::make_shared>(); - const auto callback = [=] { - if (*box) { - (*box)->closeBox(); - } + const auto callback = [=](Fn &&close) { + close(); Core::App().logout(&session->account()); }; - *box = Ui::show(Box( + Ui::show(Box( tr::lng_sure_logout(tr::now), tr::lng_settings_logout(tr::now), st::attentionBoxButton, diff --git a/Telegram/SourceFiles/window/window_peer_menu.cpp b/Telegram/SourceFiles/window/window_peer_menu.cpp index fb03c1c69..3df53dc55 100644 --- a/Telegram/SourceFiles/window/window_peer_menu.cpp +++ b/Telegram/SourceFiles/window/window_peer_menu.cpp @@ -1039,15 +1039,12 @@ QPointer ShowSendNowMessagesBox( }); return { nullptr }; } - const auto box = std::make_shared>(); auto done = [ =, list = std::move(items), callback = std::move(successCallback) - ]() mutable { - if (*box) { - (*box)->closeBox(); - } + ](Fn &&close) mutable { + close(); auto ids = QVector(); for (const auto item : session->data().idsToItems(list)) { if (item->allowsSendNow()) { @@ -1067,10 +1064,9 @@ QPointer ShowSendNowMessagesBox( callback(); } }; - *box = Ui::show( + return Ui::show( Box(text, tr::lng_send_button(tr::now), std::move(done)), - Ui::LayerOption::KeepOther); - return box->data(); + Ui::LayerOption::KeepOther).data(); } void PeerMenuAddChannelMembers(