From 276e47707879be3b8eda9dea145a4a8dafbb5a32 Mon Sep 17 00:00:00 2001 From: Andreas Blaesius Date: Mon, 27 Sep 2021 09:53:28 +0200 Subject: [PATCH] collage: remove all images from gallery on discard/delete from result screen Change-Id: Id24c284e6dc0f0ce3c95eecb10ea9df91aa8ff6c --- api/applyEffects.php | 1 + src/js/core.js | 33 +++++++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/api/applyEffects.php b/api/applyEffects.php index 912681754..718c96711 100644 --- a/api/applyEffects.php +++ b/api/applyEffects.php @@ -269,4 +269,5 @@ echo json_encode([ 'file' => $file, + 'images' => $srcImages, ]); diff --git a/src/js/core.js b/src/js/core.js index 84c1cc35c..971c7af07 100644 --- a/src/js/core.js +++ b/src/js/core.js @@ -630,6 +630,7 @@ const photoBooth = (function () { endTime = new Date().getTime(); totalTime = endTime - startTime; photoboothTools.console.logDev('Processing ' + photoStyle + ' took ' + totalTime + 'ms'); + photoboothTools.console.logDev('Images:', data.images); if (config.get_request.processed) { const getUrl = config.get_request.server + '/' + photoStyle; @@ -644,7 +645,7 @@ const photoBooth = (function () { } else if (photoStyle === 'chroma') { api.renderChroma(data.file); } else { - api.renderPic(data.file); + api.renderPic(data.file, data.images); } }, error: (jqXHR, textStatus) => { @@ -688,7 +689,7 @@ const photoBooth = (function () { }; // Render Picture after taking - api.renderPic = function (filename) { + api.renderPic = function (filename, files) { // Add QR Code Image const qrCodeModal = $('#qrCode'); photoboothTools.modal.empty(qrCodeModal); @@ -739,23 +740,27 @@ const photoBooth = (function () { const msg = photoboothTools.getTranslation('really_delete_image'); const really = config.delete.no_request ? true : confirm(filename + ' ' + msg); if (really) { - api.deleteImage(filename, (data) => { - if (data.success) { - photoboothTools.console.log('Deleted ' + filename); - photoboothTools.reloadPage(); - } else { - photoboothTools.console.log('Error while deleting ' + filename); - if (data.error) { - photoboothTools.console.log(data.error); + files.forEach(function (file, index, array) { + photoboothTools.console.logDev('Index:', index); + photoboothTools.console.logDev('Array:', array); + api.deleteImage(file, (data) => { + if (data.success) { + photoboothTools.console.log('Deleted ' + file); + } else { + photoboothTools.console.log('Error while deleting ' + file); + if (data.error) { + photoboothTools.console.log(data.error); + } + setTimeout(function () { + photoboothTools.reloadPage(); + }, 5000); } - setTimeout(function () { - photoboothTools.reloadPage(); - }, 5000); - } + }); }); } else { $('.deletebtn').blur(); } + photoboothTools.reloadPage(); }); // Add Image to gallery and slider