From 704e3c94236f2e3dce1e210154fc614e3899c845 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 17 Apr 2018 19:41:52 +0400 Subject: [PATCH] Don't save values while uploading scans. --- .../passport/passport_form_controller.cpp | 22 ++++++++++++++++++- .../passport/passport_form_controller.h | 1 + .../SourceFiles/passport/passport_panel.cpp | 1 + Telegram/SourceFiles/window/layer_widget.cpp | 8 ++++++- Telegram/SourceFiles/window/layer_widget.h | 2 ++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/Telegram/SourceFiles/passport/passport_form_controller.cpp b/Telegram/SourceFiles/passport/passport_form_controller.cpp index 8b5b8e62a..b17f5a1e2 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.cpp +++ b/Telegram/SourceFiles/passport/passport_form_controller.cpp @@ -1015,7 +1015,27 @@ void FormController::fileLoadFail(FileKey key) { bool FormController::savingValue(not_null value) const { return (value->saveRequestId != 0) || (value->verification.requestId != 0) - || (value->verification.codeLength != 0); + || (value->verification.codeLength != 0) + || uploadingScan(value); +} + +bool FormController::uploadingScan(not_null value) const { + for (const auto &scan : value->scansInEdit) { + if (scan.uploadData + && scan.uploadData->fullId + && !scan.deleted) { + return true; + } + } + if (value->selfieInEdit) { + const auto &selfie = *value->selfieInEdit; + if (selfie.uploadData + && selfie.uploadData->fullId + && !selfie.deleted) { + return true; + } + } + return false; } void FormController::cancelValueEdit(not_null value) { diff --git a/Telegram/SourceFiles/passport/passport_form_controller.h b/Telegram/SourceFiles/passport/passport_form_controller.h index ad88bcaf6..09eb415e9 100644 --- a/Telegram/SourceFiles/passport/passport_form_controller.h +++ b/Telegram/SourceFiles/passport/passport_form_controller.h @@ -263,6 +263,7 @@ public: void saveValueEdit(not_null value, ValueMap &&data); void deleteValueEdit(not_null value); bool savingValue(not_null value) const; + bool uploadingScan(not_null value) const; void cancel(); void cancelSure(); diff --git a/Telegram/SourceFiles/passport/passport_panel.cpp b/Telegram/SourceFiles/passport/passport_panel.cpp index f7d464b00..68a5893c5 100644 --- a/Telegram/SourceFiles/passport/passport_panel.cpp +++ b/Telegram/SourceFiles/passport/passport_panel.cpp @@ -265,6 +265,7 @@ void Panel::ensureLayerCreated() { return; } _layer.create(_body); + _layer->setHideByBackgroundClick(false); _layer->move(0, 0); _body->sizeValue( ) | rpl::start_with_next([=](QSize size) { diff --git a/Telegram/SourceFiles/window/layer_widget.cpp b/Telegram/SourceFiles/window/layer_widget.cpp index f5ef4d5d9..36d5fdce0 100644 --- a/Telegram/SourceFiles/window/layer_widget.cpp +++ b/Telegram/SourceFiles/window/layer_widget.cpp @@ -345,6 +345,10 @@ bool LayerWidget::overlaps(const QRect &globalRect) { return false; } +void LayerStackWidget::setHideByBackgroundClick(bool hide) { + _hideByBackgroundClick = hide; +} + void LayerStackWidget::keyPressEvent(QKeyEvent *e) { if (e->key() == Qt::Key_Escape) { hideCurrent(anim::type::normal); @@ -352,7 +356,9 @@ void LayerStackWidget::keyPressEvent(QKeyEvent *e) { } void LayerStackWidget::mousePressEvent(QMouseEvent *e) { - hideCurrent(anim::type::normal); + if (_hideByBackgroundClick) { + hideCurrent(anim::type::normal); + } } void LayerStackWidget::hideCurrent(anim::type animated) { diff --git a/Telegram/SourceFiles/window/layer_widget.h b/Telegram/SourceFiles/window/layer_widget.h index 9c7899ddf..9a25a6fac 100644 --- a/Telegram/SourceFiles/window/layer_widget.h +++ b/Telegram/SourceFiles/window/layer_widget.h @@ -107,6 +107,7 @@ public: void hideLayers(anim::type animated); void hideAll(anim::type animated); void hideTopLayer(anim::type animated); + void setHideByBackgroundClick(bool hide); bool showSectionInternal( not_null memento, @@ -183,6 +184,7 @@ private: class BackgroundWidget; object_ptr _background; + bool _hideByBackgroundClick = true; rpl::event_stream<> _hideFinishStream;