Skip to content

Commit

Permalink
Fixes image delete infinite polling after delete.
Browse files Browse the repository at this point in the history
Recognises soft deleted as a deleted.
Returns promise to that it can be waited on.
  • Loading branch information
tonytw1 committed Dec 29, 2024
1 parent 7f11ad8 commit db7c10c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions kahuna/public/js/components/gr-delete-image/gr-delete-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit db7c10c

Please sign in to comment.