mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 14:07:49 -06:00
fix: Change return type of upload route
This commit is contained in:
@@ -208,7 +208,7 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
final file = await _assembleFileBytes(
|
||||
context.read<DocumentScannerCubit>().state,
|
||||
);
|
||||
final taskId = await Navigator.of(context).push<String?>(
|
||||
final uploadResult = await Navigator.of(context).push<DocumentUploadResult>(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => LabelRepositoriesProvider(
|
||||
child: BlocProvider(
|
||||
@@ -228,10 +228,12 @@ class _ScannerPageState extends State<ScannerPage>
|
||||
),
|
||||
),
|
||||
);
|
||||
if (taskId != null) {
|
||||
if ((uploadResult?.success ?? false) && uploadResult?.taskId != null) {
|
||||
// For paperless version older than 1.11.3, task id will always be null!
|
||||
context.read<DocumentScannerCubit>().reset();
|
||||
context.read<TaskStatusCubit>().listenToTaskChanges(taskId);
|
||||
context
|
||||
.read<TaskStatusCubit>()
|
||||
.listenToTaskChanges(uploadResult!.taskId!);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,13 @@ import 'package:paperless_mobile/generated/l10n/app_localizations.dart';
|
||||
|
||||
import 'package:paperless_mobile/helpers/message_helpers.dart';
|
||||
|
||||
class DocumentUploadResult {
|
||||
final bool success;
|
||||
final String? taskId;
|
||||
|
||||
DocumentUploadResult(this.success, this.taskId);
|
||||
}
|
||||
|
||||
class DocumentUploadPreparationPage extends StatefulWidget {
|
||||
final Uint8List fileBytes;
|
||||
final String? title;
|
||||
@@ -259,13 +266,19 @@ class _DocumentUploadPreparationPageState
|
||||
createdAt: createdAt,
|
||||
);
|
||||
showSnackBar(
|
||||
context, S.of(context)!.documentSuccessfullyUploadedProcessing);
|
||||
Navigator.pop(context, taskId);
|
||||
context,
|
||||
S.of(context)!.documentSuccessfullyUploadedProcessing,
|
||||
);
|
||||
Navigator.pop(
|
||||
context,
|
||||
DocumentUploadResult(true, taskId),
|
||||
);
|
||||
} on PaperlessServerException catch (error, stackTrace) {
|
||||
showErrorMessage(context, error, stackTrace);
|
||||
} on PaperlessValidationErrors catch (errors) {
|
||||
setState(() => _errors = errors);
|
||||
} catch (unknownError, stackTrace) {
|
||||
debugPrint(unknownError.toString());
|
||||
showErrorMessage(
|
||||
context, const PaperlessServerException.unknown(), stackTrace);
|
||||
} finally {
|
||||
|
||||
@@ -156,7 +156,7 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
final extension = p.extension(mediaFile.path);
|
||||
if (await File(mediaFile.path).exists()) {
|
||||
final bytes = File(mediaFile.path).readAsBytesSync();
|
||||
final success = await Navigator.push<bool>(
|
||||
final result = await Navigator.push<DocumentUploadResult>(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => BlocProvider.value(
|
||||
@@ -174,9 +174,8 @@ class _HomePageState extends State<HomePage> with WidgetsBindingObserver {
|
||||
),
|
||||
),
|
||||
),
|
||||
) ??
|
||||
false;
|
||||
if (success) {
|
||||
);
|
||||
if (result?.success ?? false) {
|
||||
await Fluttertoast.showToast(
|
||||
msg: S.of(context)!.documentSuccessfullyUploadedProcessing,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user