Replaced 'Delete permanently' dialog with the new one
This commit is contained in:
parent
effea1cf47
commit
df819cc5a1
1 changed files with 26 additions and 25 deletions
|
@ -262,36 +262,37 @@ Future<void> deleteFilesOnDeviceOnly(
|
|||
}
|
||||
|
||||
Future<bool> deleteFromTrash(BuildContext context, List<File> files) async {
|
||||
final result = await showChoiceDialog(
|
||||
final result = await showNewChoiceDialog(
|
||||
context,
|
||||
"Delete permanently?",
|
||||
"This action cannot be undone",
|
||||
firstAction: "Delete",
|
||||
actionType: ActionType.critical,
|
||||
title: "Delete permanently",
|
||||
body: "This action cannot be undone",
|
||||
firstButtonLabel: "Delete",
|
||||
isCritical: true,
|
||||
firstButtonOnTap: () async {
|
||||
try {
|
||||
await TrashSyncService.instance.deleteFromTrash(files);
|
||||
Bus.instance.fire(
|
||||
FilesUpdatedEvent(
|
||||
files,
|
||||
type: EventType.deletedFromEverywhere,
|
||||
source: "deleteFromTrash",
|
||||
),
|
||||
);
|
||||
} catch (e, s) {
|
||||
_logger.info("failed to delete from trash", e, s);
|
||||
rethrow;
|
||||
}
|
||||
},
|
||||
);
|
||||
if (result != DialogUserChoice.firstChoice) {
|
||||
return false;
|
||||
}
|
||||
final dialog = createProgressDialog(context, "Permanently deleting...");
|
||||
await dialog.show();
|
||||
try {
|
||||
await TrashSyncService.instance.deleteFromTrash(files);
|
||||
showShortToast(context, "Successfully deleted");
|
||||
await dialog.hide();
|
||||
Bus.instance.fire(
|
||||
FilesUpdatedEvent(
|
||||
files,
|
||||
type: EventType.deletedFromEverywhere,
|
||||
source: "deleteFromTrash",
|
||||
),
|
||||
);
|
||||
return true;
|
||||
} catch (e, s) {
|
||||
_logger.info("failed to delete from trash", e, s);
|
||||
await dialog.hide();
|
||||
if (result == ButtonAction.error) {
|
||||
await showGenericErrorDialog(context: context);
|
||||
return false;
|
||||
}
|
||||
if (result == null || result == ButtonAction.cancel) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> emptyTrash(BuildContext context) async {
|
||||
|
|
Loading…
Reference in a new issue