Skip to content

Commit

Permalink
Update create_manifest_cubit.dart
Browse files Browse the repository at this point in the history
handle error on manifest upload
  • Loading branch information
thiagocarvalhodev committed May 13, 2024
1 parent c7a97c5 commit ac28404
Showing 1 changed file with 25 additions and 22 deletions.
47 changes: 25 additions & 22 deletions lib/blocs/create_manifest/create_manifest_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -220,29 +220,32 @@ class CreateManifestCubit extends Cubit<CreateManifestState> {
}

if (state is CreateManifestUploadReview) {
final createManifestUploadReview = state as CreateManifestUploadReview;
final uploadType =
createManifestUploadReview.uploadMethod == UploadMethod.ar
? UploadType.d2n
: UploadType.turbo;

emit(CreateManifestUploadInProgress());

await _manifestRepository.uploadManifest(
params: ManifestUploadParams(
manifestFile: createManifestUploadReview.manifestFile,
driveId: _drive.id,
parentFolderId: createManifestUploadReview.parentFolder.id,
existingManifestFileId:
createManifestUploadReview.existingManifestFileId,
uploadType: uploadType,
wallet: _auth.currentUser.wallet,
),
);

emit(CreateManifestSuccess());
try {
final createManifestUploadReview = state as CreateManifestUploadReview;
final uploadType =
createManifestUploadReview.uploadMethod == UploadMethod.ar
? UploadType.d2n
: UploadType.turbo;

emit(CreateManifestUploadInProgress());

await _manifestRepository.uploadManifest(
params: ManifestUploadParams(
manifestFile: createManifestUploadReview.manifestFile,
driveId: _drive.id,
parentFolderId: createManifestUploadReview.parentFolder.id,
existingManifestFileId:
createManifestUploadReview.existingManifestFileId,
uploadType: uploadType,
wallet: _auth.currentUser.wallet,
),
);

return;
emit(CreateManifestSuccess());
} catch (e) {
logger.e('An error occured uploading the manifest.', e);
addError(e);
}
}
}

Expand Down

0 comments on commit ac28404

Please sign in to comment.