From db7c10cc99c1b27b9f9bf5c6bcf8244af9c8ad84 Mon Sep 17 00:00:00 2001 From: Tony McCrae Date: Sun, 29 Dec 2024 14:57:34 +0000 Subject: [PATCH] Fixes image delete infinite polling after delete. Recognises soft deleted as a deleted. Returns promise to that it can be waited on. --- .../js/components/gr-delete-image/gr-delete-image.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kahuna/public/js/components/gr-delete-image/gr-delete-image.js b/kahuna/public/js/components/gr-delete-image/gr-delete-image.js index d139be47c8..7de55905c1 100644 --- a/kahuna/public/js/components/gr-delete-image/gr-delete-image.js +++ b/kahuna/public/js/components/gr-delete-image/gr-delete-image.js @@ -14,12 +14,19 @@ deleteImage.controller('grDeleteImageCtrl', [ this.$onInit = () => { function pollDeleted (image) { const findImage = () => mediaApi.find(image.data.id).then( - () => $q.reject(), + (r) => { + if (r.data.softDeletedMetadata) { + // resolve when image has been soft deleted. + return $q.resolve(); + } else { + return $q.reject(); + } + }, // resolve when image cannot be found, i.e. image has been deleted. () => $q.resolve() ); - apiPoll(findImage); + return apiPoll(findImage); } ctrl.deleteImage = function (image) {