Don't save values while uploading scans.

This commit is contained in:
John Preston 2018-04-17 19:41:52 +04:00
parent 67ea175fc6
commit 704e3c9423
5 changed files with 32 additions and 2 deletions

View File

@ -1015,7 +1015,27 @@ void FormController::fileLoadFail(FileKey key) {
bool FormController::savingValue(not_null<const Value*> 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<const Value*> 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<const Value*> value) {

View File

@ -263,6 +263,7 @@ public:
void saveValueEdit(not_null<const Value*> value, ValueMap &&data);
void deleteValueEdit(not_null<const Value*> value);
bool savingValue(not_null<const Value*> value) const;
bool uploadingScan(not_null<const Value*> value) const;
void cancel();
void cancelSure();

View File

@ -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) {

View File

@ -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) {

View File

@ -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<SectionMemento*> memento,
@ -183,6 +184,7 @@ private:
class BackgroundWidget;
object_ptr<BackgroundWidget> _background;
bool _hideByBackgroundClick = true;
rpl::event_stream<> _hideFinishStream;