Hide payments webview progress when destroying.

This commit is contained in:
John Preston 2021-04-13 14:05:31 +04:00
parent 0ead0879d7
commit 73c63cb2c7
3 changed files with 27 additions and 4 deletions

View file

@ -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"(

View file

@ -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<int> _formScrollTop;
QPointer<EditInformation> _weakEditInformation;
QPointer<EditCard> _weakEditCard;
bool _webviewProgress = false;
bool _testMode = false;
};

@ -1 +1 @@
Subproject commit fa6828443c71932de74ec2a0ffa5f3e8d3bc894c
Subproject commit d7caf94d64aebb6720712150457cfb1c0d5f7ca0