From 0427f90649f143d1cda16d3104c316fb907b81a6 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Fri, 15 Apr 2022 12:36:06 +0300 Subject: [PATCH] Removed label from confirm box when text is not provided. --- Telegram/SourceFiles/ui/boxes/confirm_box.cpp | 21 +++++++++++-------- Telegram/SourceFiles/ui/boxes/confirm_box.h | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Telegram/SourceFiles/ui/boxes/confirm_box.cpp b/Telegram/SourceFiles/ui/boxes/confirm_box.cpp index cad5137ebb..c048b2354f 100644 --- a/Telegram/SourceFiles/ui/boxes/confirm_box.cpp +++ b/Telegram/SourceFiles/ui/boxes/confirm_box.cpp @@ -17,12 +17,18 @@ void ConfirmBox(not_null box, ConfirmBoxArgs &&args) { const auto weak = Ui::MakeWeak(box); const auto lifetime = box->lifetime().make_state(); - const auto label = box->addRow( - object_ptr( - box.get(), - v::text::take_marked(std::move(args.text)), - args.labelStyle ? *args.labelStyle : st::boxLabel), - st::boxPadding); + v::match(args.text, [](v::null_t) { + }, [&](auto &&) { + const auto label = box->addRow( + object_ptr( + box.get(), + v::text::take_marked(std::move(args.text)), + args.labelStyle ? *args.labelStyle : st::boxLabel), + st::boxPadding); + if (args.labelFilter) { + label->setClickHandlerFilter(std::move(args.labelFilter)); + } + }); const auto prepareCallback = [&](ConfirmBoxArgs::Callback &callback) { return [=, confirmed = std::move(callback)]() { @@ -75,9 +81,6 @@ void ConfirmBox(not_null box, ConfirmBoxArgs &&args) { }), *lifetime); } - if (args.labelFilter) { - label->setClickHandlerFilter(std::move(args.labelFilter)); - } if (args.strictCancel) { lifetime->destroy(); } diff --git a/Telegram/SourceFiles/ui/boxes/confirm_box.h b/Telegram/SourceFiles/ui/boxes/confirm_box.h index 9a340c7bd6..297909f693 100644 --- a/Telegram/SourceFiles/ui/boxes/confirm_box.h +++ b/Telegram/SourceFiles/ui/boxes/confirm_box.h @@ -18,7 +18,7 @@ struct ConfirmBoxArgs { Fn, Fn)>>; - v::text::data text; + v::text::data text = v::null; Callback confirmed = v::null; Callback cancelled = v::null;