mirror of https://github.com/procxx/kepka.git
				
				
				
			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) { | 	for (auto &scan : nonconst->scans) { | ||||||
| 		loadFile(scan); | 		loadFile(scan); | ||||||
| 	} | 	} | ||||||
| 	if (nonconst->selfie) { | 	if (nonconst->selfie && _form.identitySelfieRequired) { | ||||||
| 		loadFile(*nonconst->selfie); | 		loadFile(*nonconst->selfie); | ||||||
| 	} | 	} | ||||||
| 	nonconst->scansInEdit = ranges::view::all( | 	nonconst->scansInEdit = ranges::view::all( | ||||||
|  |  | ||||||
|  | @ -370,29 +370,8 @@ void EditScans::setupContent(const QString &header) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void EditScans::updateScan(ScanInfo &&info) { | 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) { | 	if (info.selfie) { | ||||||
| 		Assert(info.key.id != 0); | 		updateSelfie(std::move(info)); | ||||||
| 		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); |  | ||||||
| 		return; | 		return; | ||||||
| 	} | 	} | ||||||
| 	const auto i = ranges::find(_files, info.key, [](const ScanInfo &file) { | 	const auto i = ranges::find(_files, info.key, [](const ScanInfo &file) { | ||||||
|  | @ -401,9 +380,7 @@ void EditScans::updateScan(ScanInfo &&info) { | ||||||
| 	if (i != _files.end()) { | 	if (i != _files.end()) { | ||||||
| 		*i = std::move(info); | 		*i = std::move(info); | ||||||
| 		const auto scan = _rows[i - _files.begin()]->entity(); | 		const auto scan = _rows[i - _files.begin()]->entity(); | ||||||
| 		scan->setStatus(i->status); | 		updateFileRow(scan, *i); | ||||||
| 		scan->setImage(i->thumb); |  | ||||||
| 		scan->setDeleted(i->deleted); |  | ||||||
| 		if (!i->deleted) { | 		if (!i->deleted) { | ||||||
| 			hideError(); | 			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) { | void EditScans::createSelfieRow(const ScanInfo &info) { | ||||||
| 	_selfieRow = createScan( | 	_selfieRow = createScan( | ||||||
| 		_selfieWrap, | 		_selfieWrap, | ||||||
|  |  | ||||||
|  | @ -51,6 +51,10 @@ private: | ||||||
| 	void chooseScan(); | 	void chooseScan(); | ||||||
| 	void chooseSelfie(); | 	void chooseSelfie(); | ||||||
| 	void updateScan(ScanInfo &&info); | 	void updateScan(ScanInfo &&info); | ||||||
|  | 	void updateSelfie(ScanInfo &&info); | ||||||
|  | 	void updateFileRow( | ||||||
|  | 		not_null<ScanButton*> button, | ||||||
|  | 		const ScanInfo &info); | ||||||
| 	void pushScan(const ScanInfo &info); | 	void pushScan(const ScanInfo &info); | ||||||
| 	void createSelfieRow(const ScanInfo &info); | 	void createSelfieRow(const ScanInfo &info); | ||||||
| 	base::unique_qptr<Ui::SlideWrap<ScanButton>> createScan( | 	base::unique_qptr<Ui::SlideWrap<ScanButton>> createScan( | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue