From 4ef550da9bd1e710097143a0beb98322e9750ad8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 30 Sep 2021 14:53:18 +0400 Subject: [PATCH] Hide webview while showing a box in payments. --- .../payments/ui/payments_panel.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index 724cbcada..26e6977f2 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -49,6 +49,7 @@ struct Panel::WebviewWithLifetime { Webview::WindowConfig config = Webview::WindowConfig()); Webview::Window window; + QPointer lastHidingBox; rpl::lifetime lifetime; }; @@ -687,6 +688,26 @@ rpl::producer<> Panel::backRequests() const { } void Panel::showBox(object_ptr box) { + if (const auto widget = _webview ? _webview->window.widget() : nullptr) { + const auto hideNow = !widget->isHidden(); + if (hideNow || _webview->lastHidingBox) { + const auto raw = _webview->lastHidingBox = box.data(); + box->boxClosing( + ) | rpl::start_with_next([=] { + const auto widget = _webview + ? _webview->window.widget() + : nullptr; + if (widget + && widget->isHidden() + && _webview->lastHidingBox == raw) { + widget->show(); + } + }, _webview->lifetime); + if (hideNow) { + widget->hide(); + } + } + } _widget->showBox( std::move(box), LayerOption::KeepOther,