Fix passport selfie requirements.
This commit is contained in:
parent
67e698a374
commit
60582a24ab
|
@ -1004,7 +1004,7 @@ void FormController::startValueEdit(not_null<const Value*> value) {
|
|||
for (auto &scan : nonconst->scans) {
|
||||
loadFile(scan);
|
||||
}
|
||||
if (nonconst->selfie) {
|
||||
if (nonconst->selfie && _form.identitySelfieRequired) {
|
||||
loadFile(*nonconst->selfie);
|
||||
}
|
||||
nonconst->scansInEdit = ranges::view::all(
|
||||
|
|
|
@ -370,29 +370,8 @@ void EditScans::setupContent(const QString &header) {
|
|||
}
|
||||
|
||||
void EditScans::updateScan(ScanInfo &&info) {
|
||||
const auto updateRow = [&](
|
||||
not_null<ScanButton*> button,
|
||||
const ScanInfo &info) {
|
||||
button->setStatus(info.status);
|
||||
button->setImage(info.thumb);
|
||||
button->setDeleted(info.deleted);
|
||||
button->setError(!info.error.isEmpty());
|
||||
};
|
||||
if (info.selfie) {
|
||||
Assert(info.key.id != 0);
|
||||
Assert(_selfie != nullptr);
|
||||
if (_selfie->key.id) {
|
||||
updateRow(_selfieRow->entity(), info);
|
||||
if (!info.deleted) {
|
||||
hideSelfieError();
|
||||
}
|
||||
} else {
|
||||
createSelfieRow(info);
|
||||
_selfieWrap->resizeToWidth(width());
|
||||
_selfieRow->show(anim::type::normal);
|
||||
_selfieHeader->show(anim::type::normal);
|
||||
}
|
||||
*_selfie = std::move(info);
|
||||
updateSelfie(std::move(info));
|
||||
return;
|
||||
}
|
||||
const auto i = ranges::find(_files, info.key, [](const ScanInfo &file) {
|
||||
|
@ -401,9 +380,7 @@ void EditScans::updateScan(ScanInfo &&info) {
|
|||
if (i != _files.end()) {
|
||||
*i = std::move(info);
|
||||
const auto scan = _rows[i - _files.begin()]->entity();
|
||||
scan->setStatus(i->status);
|
||||
scan->setImage(i->thumb);
|
||||
scan->setDeleted(i->deleted);
|
||||
updateFileRow(scan, *i);
|
||||
if (!i->deleted) {
|
||||
hideError();
|
||||
}
|
||||
|
@ -421,6 +398,36 @@ void EditScans::updateScan(ScanInfo &&info) {
|
|||
}
|
||||
}
|
||||
|
||||
void EditScans::updateSelfie(ScanInfo &&info) {
|
||||
Expects(info.key.id != 0);
|
||||
|
||||
if (!_selfie) {
|
||||
return;
|
||||
}
|
||||
if (_selfie->key.id) {
|
||||
updateFileRow(_selfieRow->entity(), info);
|
||||
if (!info.deleted) {
|
||||
hideSelfieError();
|
||||
}
|
||||
} else {
|
||||
createSelfieRow(info);
|
||||
_selfieWrap->resizeToWidth(width());
|
||||
_selfieRow->show(anim::type::normal);
|
||||
_selfieHeader->show(anim::type::normal);
|
||||
}
|
||||
*_selfie = std::move(info);
|
||||
}
|
||||
|
||||
void EditScans::updateFileRow(
|
||||
not_null<ScanButton*> button,
|
||||
const ScanInfo &info) {
|
||||
button->setStatus(info.status);
|
||||
button->setImage(info.thumb);
|
||||
button->setDeleted(info.deleted);
|
||||
button->setError(!info.error.isEmpty());
|
||||
};
|
||||
|
||||
|
||||
void EditScans::createSelfieRow(const ScanInfo &info) {
|
||||
_selfieRow = createScan(
|
||||
_selfieWrap,
|
||||
|
|
|
@ -51,6 +51,10 @@ private:
|
|||
void chooseScan();
|
||||
void chooseSelfie();
|
||||
void updateScan(ScanInfo &&info);
|
||||
void updateSelfie(ScanInfo &&info);
|
||||
void updateFileRow(
|
||||
not_null<ScanButton*> button,
|
||||
const ScanInfo &info);
|
||||
void pushScan(const ScanInfo &info);
|
||||
void createSelfieRow(const ScanInfo &info);
|
||||
base::unique_qptr<Ui::SlideWrap<ScanButton>> createScan(
|
||||
|
|
Loading…
Reference in New Issue