diff --git a/lib/features/document_upload/cubit/document_upload_cubit.dart b/lib/features/document_upload/cubit/document_upload_cubit.dart index 86019a9..bfe4f50 100644 --- a/lib/features/document_upload/cubit/document_upload_cubit.dart +++ b/lib/features/document_upload/cubit/document_upload_cubit.dart @@ -44,6 +44,7 @@ class DocumentUploadCubit extends Cubit { Iterable tags = const [], DateTime? createdAt, int? asn, + void Function(double)? onProgressChanged, }) async { final taskId = await _documentApi.create( bytes, @@ -54,6 +55,7 @@ class DocumentUploadCubit extends Cubit { tags: tags, createdAt: createdAt, asn: asn, + onProgressChanged: onProgressChanged, ); if (taskId != null) { _tasksNotifier.listenToTaskChanges(taskId); diff --git a/lib/features/sharing/cubit/receive_share_cubit.dart b/lib/features/sharing/cubit/receive_share_cubit.dart index 19317d4..facaada 100644 --- a/lib/features/sharing/cubit/receive_share_cubit.dart +++ b/lib/features/sharing/cubit/receive_share_cubit.dart @@ -23,27 +23,28 @@ class ConsumptionChangeNotifier extends ChangeNotifier { } /// Creates a local copy of all shared files and reloads all files - /// from the user's consumption directory. - Future addFiles({ + /// from the user's consumption directory. Returns the newly added files copied to the consumption directory. + Future> addFiles({ required List files, required String userId, }) async { if (files.isEmpty) { - return; + return []; } final consumptionDirectory = await FileService.getConsumptionDirectory(userId: userId); + final List localFiles = []; for (final file in files) { - File localFile; - if (file.path.startsWith(consumptionDirectory.path)) { - localFile = file; + if (!file.path.startsWith(consumptionDirectory.path)) { + final localFile = await file + .copy(p.join(consumptionDirectory.path, p.basename(file.path))); + localFiles.add(localFile); } else { - final fileName = p.basename(file.path); - localFile = File(p.join(consumptionDirectory.path, fileName)); - await file.copy(localFile.path); + localFiles.add(file); } } - return loadFromConsumptionDirectory(userId: userId); + await loadFromConsumptionDirectory(userId: userId); + return localFiles; } /// Marks a file as processed by removing it from the queue and deleting the local copy of the file. diff --git a/lib/features/sharing/view/widgets/event_listener_shell.dart b/lib/features/sharing/view/widgets/event_listener_shell.dart index 55f82b6..ff637e2 100644 --- a/lib/features/sharing/view/widgets/event_listener_shell.dart +++ b/lib/features/sharing/view/widgets/event_listener_shell.dart @@ -141,13 +141,13 @@ class _EventListenerShellState extends State if (files.isNotEmpty) { final userId = context.read().id; final notifier = context.read(); - await notifier.addFiles( + final addedLocalFiles = await notifier.addFiles( files: files, userId: userId, ); consumeLocalFiles( context, - files: files, + files: addedLocalFiles, userId: userId, exitAppAfterConsumed: true, ); diff --git a/lib/routes/typed/branches/upload_queue_route.dart b/lib/routes/typed/branches/upload_queue_route.dart index 77521e5..0c3ebb2 100644 --- a/lib/routes/typed/branches/upload_queue_route.dart +++ b/lib/routes/typed/branches/upload_queue_route.dart @@ -4,12 +4,6 @@ import 'package:paperless_mobile/features/sharing/view/consumption_queue_view.da import 'package:paperless_mobile/routes/navigation_keys.dart'; import 'package:paperless_mobile/routes/routes.dart'; -part 'upload_queue_route.g.dart'; - -@TypedGoRoute( - path: "/upload-queue", - name: R.uploadQueue, -) class UploadQueueRoute extends GoRouteData { static final GlobalKey $parentNavigatorKey = outerShellNavigatorKey; diff --git a/lib/routes/typed/shells/authenticated_route.dart b/lib/routes/typed/shells/authenticated_route.dart index 8f66d59..2efc608 100644 --- a/lib/routes/typed/shells/authenticated_route.dart +++ b/lib/routes/typed/shells/authenticated_route.dart @@ -20,6 +20,7 @@ import 'package:paperless_mobile/routes/typed/branches/inbox_route.dart'; import 'package:paperless_mobile/routes/typed/branches/labels_route.dart'; import 'package:paperless_mobile/routes/typed/branches/landing_route.dart'; import 'package:paperless_mobile/routes/typed/branches/scanner_route.dart'; +import 'package:paperless_mobile/routes/typed/branches/upload_queue_route.dart'; import 'package:paperless_mobile/routes/typed/shells/scaffold_shell_route.dart'; import 'package:paperless_mobile/routes/typed/top_level/settings_route.dart'; import 'package:provider/provider.dart'; @@ -34,6 +35,10 @@ part 'authenticated_route.g.dart'; path: "/settings", name: R.settings, ), + TypedGoRoute( + path: "/upload-queue", + name: R.uploadQueue, + ), TypedStatefulShellRoute( branches: [ TypedStatefulShellBranch( diff --git a/packages/paperless_api/lib/src/modules/documents_api/paperless_documents_api.dart b/packages/paperless_api/lib/src/modules/documents_api/paperless_documents_api.dart index 09560aa..ccbad6d 100644 --- a/packages/paperless_api/lib/src/modules/documents_api/paperless_documents_api.dart +++ b/packages/paperless_api/lib/src/modules/documents_api/paperless_documents_api.dart @@ -14,6 +14,7 @@ abstract class PaperlessDocumentsApi { int? correspondent, Iterable tags = const [], int? asn, + void Function(double progress)? onProgressChanged, }); Future update(DocumentModel doc); Future findNextAsn();