DeleteAll updated

modify deleteAll to only delete the images listed in the drawer
This commit is contained in:
Silversith 2023-04-11 10:25:23 +02:00
parent 0b829dc4d4
commit a95f4e9757
3 changed files with 7 additions and 6 deletions

View File

@ -187,8 +187,8 @@ class PromptServer():
if not os.path.exists(output_dir): if not os.path.exists(output_dir):
return web.json_response({"message": "Output directory does not exist."}, status=404) return web.json_response({"message": "Output directory does not exist."}, status=404)
try: try:
if (filename == "all"): if isinstance(filename, list):
for file_name in os.listdir(output_dir): for file_name in filename: #os.listdir(output_dir):
file_path = os.path.join(output_dir, file_name) file_path = os.path.join(output_dir, file_name)
if os.path.isfile(file_path): if os.path.isfile(file_path):
os.remove(file_path) os.remove(file_path)

View File

@ -210,9 +210,10 @@ app.registerExtension({
right: "5px", right: "5px",
}); });
deleteAllButton.onclick = () => { deleteAllButton.onclick = () => {
const confirmDelete = confirm("Are you sure you want to delete all images?"); const confirmDelete = confirm("Are you sure you want to delete all images in the drawer?");
if (confirmDelete) { if (confirmDelete) {
api.deleteAllImages(); debugger;
api.deleteAllImages(allImages.map(item => item.filename));
allImages = [] allImages = []
imageList.replaceChildren(menu, resizeHandle); imageList.replaceChildren(menu, resizeHandle);
} }

View File

@ -117,8 +117,8 @@ class ComfyApi extends EventTarget {
return await resp.json(); return await resp.json();
} }
async deleteAllImages() { async deleteAllImages(filenames) {
await this.#postItem("delete", { delete: "all" }) await this.#postItem("delete", { delete: filenames })
} }
async deleteImage(filename) { async deleteImage(filename) {
await this.#postItem("delete", { delete: filename }) await this.#postItem("delete", { delete: filename })