From 73c63cb2c7f38440543a466e7c9ed8ed217f9623 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 13 Apr 2021 14:05:31 +0400 Subject: [PATCH] Hide payments webview progress when destroying. --- .../payments/ui/payments_panel.cpp | 26 ++++++++++++++++--- .../SourceFiles/payments/ui/payments_panel.h | 3 +++ Telegram/lib_webview | 2 +- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.cpp b/Telegram/SourceFiles/payments/ui/payments_panel.cpp index ffca1721f5..8cb9453882 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.cpp +++ b/Telegram/SourceFiles/payments/ui/payments_panel.cpp @@ -78,6 +78,9 @@ void Panel::requestActivate() { } void Panel::toggleProgress(bool shown) { + if (!shown) { + _webviewProgress = false; + } if (!_progress) { if (!shown) { return; @@ -431,6 +434,22 @@ void Panel::showEditPaymentMethod(const PaymentMethodDetails &method) { } } +void Panel::showWebviewProgress() { + if (_webviewProgress) { + return; + } + _webviewProgress = true; + toggleProgress(true); +} + +void Panel::hideWebviewProgress() { + if (!_webviewProgress) { + return; + } + _webviewProgress = false; + toggleProgress(false); +} + bool Panel::showWebview( const QString &url, bool allowBack, @@ -438,7 +457,7 @@ bool Panel::showWebview( if (!_webview && !createWebview()) { return false; } - toggleProgress(true); + showWebviewProgress(); _widget->destroyLayer(); _webview->navigate(url); _widget->setBackAllowed(allowBack); @@ -488,6 +507,7 @@ bool Panel::createWebview() { QObject::connect(container.get(), &QObject::destroyed, [=] { if (_webview.get() == raw) { _webview = nullptr; + hideWebviewProgress(); } if (_webviewBottom.get() == bottom) { _webviewBottom = nullptr; @@ -512,11 +532,11 @@ bool Panel::createWebview() { if (!_delegate->panelWebviewNavigationAttempt(uri)) { return false; } - toggleProgress(true); + showWebviewProgress(); return true; }); raw->setNavigationDoneHandler([=](bool success) { - toggleProgress(false); + hideWebviewProgress(); }); raw->init(R"( diff --git a/Telegram/SourceFiles/payments/ui/payments_panel.h b/Telegram/SourceFiles/payments/ui/payments_panel.h index d711d75bf0..11def1482b 100644 --- a/Telegram/SourceFiles/payments/ui/payments_panel.h +++ b/Telegram/SourceFiles/payments/ui/payments_panel.h @@ -90,6 +90,8 @@ private: struct Progress; bool createWebview(); + void showWebviewProgress(); + void hideWebviewProgress(); void showWebviewError( const QString &text, const Webview::Available &information); @@ -109,6 +111,7 @@ private: rpl::variable _formScrollTop; QPointer _weakEditInformation; QPointer _weakEditCard; + bool _webviewProgress = false; bool _testMode = false; }; diff --git a/Telegram/lib_webview b/Telegram/lib_webview index fa6828443c..d7caf94d64 160000 --- a/Telegram/lib_webview +++ b/Telegram/lib_webview @@ -1 +1 @@ -Subproject commit fa6828443c71932de74ec2a0ffa5f3e8d3bc894c +Subproject commit d7caf94d64aebb6720712150457cfb1c0d5f7ca0