go to previous screen when file is deleted from trash

This commit is contained in:
Neeraj Gupta 2021-10-13 14:55:04 +05:30
parent 517a7b2a20
commit dff56f7f72
No known key found for this signature in database
GPG key ID: 3C5A1684DC1729E1
2 changed files with 9 additions and 6 deletions

View file

@ -197,8 +197,9 @@ class FadingBottomBarState extends State<FadingBottomBar> {
onPressed: () async {
final trashedFile = <TrashFile>[];
trashedFile.add(widget.file);
await deleteFromTrash(context, trashedFile);
Navigator.pop(context);
if (await deleteFromTrash(context, trashedFile) == true) {
Navigator.pop(context);
}
},
),
),

View file

@ -197,13 +197,13 @@ Future<void> deleteFilesOnDeviceOnly(
await dialog.hide();
}
Future<void> deleteFromTrash(
Future<bool> deleteFromTrash(
BuildContext context, List<TrashFile> files) async {
final result = await showChoiceDialog(context, "delete permanently?",
"the files will be permanently removed from your ente account",
firstAction: "delete", actionType: ActionType.critical);
if( result != DialogUserChoice.firstChoice) {
return;
if (result != DialogUserChoice.firstChoice) {
return false;
}
final dialog = createProgressDialog(context, "permanently deleting...");
await dialog.show();
@ -212,10 +212,12 @@ Future<void> deleteFromTrash(
showToast("successfully deleted");
await dialog.hide();
Bus.instance.fire(FilesUpdatedEvent(files, type: EventType.deleted));
return true;
} catch (e, s) {
Logger("TrashUtil").info("failed to delete from trash", e, s);
_logger.info("failed to delete from trash", e, s);
await dialog.hide();
await showGenericErrorDialog(context);
return false;
}
}