diff --git a/lib/blocs/upload/upload_cubit.dart b/lib/blocs/upload/upload_cubit.dart index c6c5ae011..d95bffe09 100644 --- a/lib/blocs/upload/upload_cubit.dart +++ b/lib/blocs/upload/upload_cubit.dart @@ -64,7 +64,7 @@ class UploadCubit extends Cubit { _arnsRepository = arnsRepository, _uploadRepository = uploadRepository, _uploadThumbnail = configService.config.uploadThumbnails, - super(UploadLoadingFiles()); + super(uploadFolders ? UploadLoadingFolders() : UploadLoadingFiles()); // Dependencies final UploadRepository _uploadRepository; diff --git a/lib/blocs/upload/upload_state.dart b/lib/blocs/upload/upload_state.dart index 906508471..ae358c487 100644 --- a/lib/blocs/upload/upload_state.dart +++ b/lib/blocs/upload/upload_state.dart @@ -306,3 +306,5 @@ enum UploadErrors { turboTimeout, unknown, } + +class UploadLoadingFolders extends UploadState {} diff --git a/lib/components/upload_form.dart b/lib/components/upload_form.dart index 10386153f..f31c413af 100644 --- a/lib/components/upload_form.dart +++ b/lib/components/upload_form.dart @@ -60,34 +60,32 @@ Future promptToUpload( }) async { final driveDetailCubit = context.read(); - final uploadCubit = BlocProvider( - create: (context) { - final cubit = UploadCubit( - activityTracker: context.read(), - arDriveUploadManager: context.read(), - uploadFileSizeChecker: context.read(), - driveId: driveId, - parentFolderId: parentFolderId, - profileCubit: context.read(), - driveDao: context.read(), - uploadFolders: isFolderUpload, - auth: context.read(), - configService: context.read(), - arnsRepository: context.read(), - uploadRepository: context.read(), - ); + final cubit = UploadCubit( + activityTracker: context.read(), + arDriveUploadManager: context.read(), + uploadFileSizeChecker: context.read(), + driveId: driveId, + parentFolderId: parentFolderId, + profileCubit: context.read(), + driveDao: context.read(), + uploadFolders: isFolderUpload, + auth: context.read(), + configService: context.read(), + arnsRepository: context.read(), + uploadRepository: context.read(), + ); - if (files != null) { - cubit.selectFiles(files, parentFolderId); - } else if (isFolderUpload) { - cubit.pickFilesFromFolder( - context: context, parentFolderId: parentFolderId); - } else { - cubit.pickFiles(context: context, parentFolderId: parentFolderId); - } + if (files != null) { + cubit.selectFiles(files, parentFolderId); + } else if (isFolderUpload) { + await cubit.pickFilesFromFolder( + context: context, parentFolderId: parentFolderId); + } else { + cubit.pickFiles(context: context, parentFolderId: parentFolderId); + } - return cubit; - }, + final uploadCubit = BlocProvider( + create: (context) => cubit, ); final uploadPaymentMethodBloc = BlocProvider(