From babe65df5696955226ebaa6121fd68dff02481a3 Mon Sep 17 00:00:00 2001 From: kevodwyer Date: Thu, 3 Aug 2023 10:20:18 +0100 Subject: [PATCH] add call to new method deleteChildren --- src/views/Drive.vue | 46 +++++++++++++++------------------------------ 1 file changed, 15 insertions(+), 31 deletions(-) diff --git a/src/views/Drive.vue b/src/views/Drive.vue index f1dd51eb..f8d9032b 100644 --- a/src/views/Drive.vue +++ b/src/views/Drive.vue @@ -2990,31 +2990,6 @@ module.exports = { this.showPrompt = true; }, - reduceDelete(index, path, parent, selectedFilesForDeletion, future) { - let that = this; - if (index == selectedFilesForDeletion.length) { - future.complete(true); - } else { - let file = selectedFilesForDeletion[index]; - let name = file.getFileProperties().name; - let filePath = peergos.client.PathUtils.toPath(path, name); - parent.getLatest(this.context.network).thenApply(updatedParent => { - file.remove(updatedParent, filePath, that.context).thenApply(function (b) { - that.updateUsage(usageBytes => { - that.updateCurrentDirectory(null , () => - that.reduceDelete(index + 1, path, parent, selectedFilesForDeletion, future) - ); - }); - }).exceptionally(function (throwable) { - that.errorTitle = 'Error deleting file: ' + file.getFileProperties().name; - that.errorBody = throwable.getMessage(); - that.showError = true; - future.complete(false); - }); - }); - } - }, - deleteFilesMultiSelect() { var selectedCount = this.selectedFiles.length; if (selectedCount == 0) @@ -3025,12 +3000,21 @@ module.exports = { if (prompt_result != null) { that.showSpinner = true; let parent = that.currentDir; - let filesToDelete = that.selectedFiles.slice(); - let future = peergos.shared.util.Futures.incomplete(); - that.reduceDelete(0, that.path, parent, filesToDelete, future); - future.thenApply(res => { - that.showSpinner = false; - that.selectedFiles = []; + let filesToDelete = peergos.client.JsUtil.asList(that.selectedFiles.slice()); + let path = that.getPath; + let parentPath = peergos.client.PathUtils.directoryToPath(path.split('/').filter(n => n.length > 0)); + peergos.shared.user.fs.FileWrapper.deleteChildren(parent, filesToDelete, parentPath, that.context).thenApply(updatedParent => { + that.updateUsage(usageBytes => { + that.updateCurrentDirectory(null , () => { + that.showSpinner = false; + that.selectedFiles = []; + }); + }); + }).exceptionally(function (throwable) { + that.errorTitle = 'Error deleting files'; + that.errorBody = throwable.getMessage(); + that.showError = true; + future.complete(false); }); } });