Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Avoid stale scanner actions after leaving review

laurenspriem85b8d5786a7c
diff --git a/mobile/apps/locker/changes/preserve-scanner-crop.md b/mobile/apps/locker/changes/preserve-scanner-crop.md
index 7727899334..af850b7b47 100644
--- a/mobile/apps/locker/changes/preserve-scanner-crop.md
+++ b/mobile/apps/locker/changes/preserve-scanner-crop.md
@@ -1 +1 @@
-- Keep the camera's detected crop when reviewing and saving scans, including automatic captures and retakes. Use the captured corners when photo refinement is inconclusive, with manual crop adjustment available as usual.
+- Keep the camera's detected crop when reviewing and saving scans, including automatic captures and retakes. Use the captured corners when photo refinement is inconclusive, with manual crop adjustment available as usual. Cancel pending exports when leaving review and keep the camera open if processing then fails.
diff --git a/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart b/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
index ec32f8f8b1..8c27b0c192 100644
--- a/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
+++ b/mobile/apps/locker/lib/ui/pages/scanner/scanner_review_page.dart
@@ -150,7 +150,9 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
void _onSessionChanged() {
if (!mounted) return;
if (widget.session.pageCount == 0 && !widget.session.isProcessing) {
- Navigator.of(context).pop(false);
+ if (ModalRoute.of(context)?.isCurrent == true) {
+ Navigator.of(context).pop(false);
+ }
return;
}
setState(() {
@@ -166,9 +168,14 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
return pages[_index.clamp(0, pages.length - 1)];
}
+ bool get _canExport =>
+ mounted &&
+ ModalRoute.of(context)?.isCurrent == true &&
+ widget.session.pageCount > 0;
+
Future<File?> _buildPdf() async {
await widget.session.waitForPending();
- if (!mounted) return null;
+ if (!_canExport) return null;
return widget.session.buildPdf();
}
@@ -184,9 +191,9 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
Future<void> _saveToEnte() => _runExclusive(() async {
final pdf = await _buildPdf();
- if (!mounted || pdf == null) return;
+ if (!_canExport || pdf == null) return;
final didUpload = await widget.onUploadFiles([pdf]);
- if (!mounted) return;
+ if (!mounted || ModalRoute.of(context)?.isCurrent != true) return;
if (didUpload) {
showShortToast(context, context.strings.scanSaved);
Navigator.of(context).pop(true);
@@ -195,7 +202,7 @@ class _ScannerReviewPageState extends State<ScannerReviewPage>
Future<void> _share() => _runExclusive(() async {
final pdf = await _buildPdf();
- if (!mounted || pdf == null) return;
+ if (!_canExport || pdf == null) return;
await SharePlus.instance.share(ShareParams(files: [XFile(pdf.path)]));
});