Skip to content

Commit

Permalink
Prevent image cache
Browse files Browse the repository at this point in the history
  • Loading branch information
jn-jairo committed Nov 11, 2023
1 parent 248aa3e commit 006b24c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions web/extensions/core/maskeditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function uploadMask(filepath, formData) {
});

ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']] = new Image();
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = api.apiURL("/view?" + new URLSearchParams(filepath).toString() + app.getPreviewFormatParam());
ComfyApp.clipspace.imgs[ComfyApp.clipspace['selectedIndex']].src = api.apiURL("/view?" + new URLSearchParams(filepath).toString() + app.getPreviewFormatParam() + app.getRandParam());

if(ComfyApp.clipspace.images)
ComfyApp.clipspace.images[ComfyApp.clipspace['selectedIndex']] = filepath;
Expand Down Expand Up @@ -657,4 +657,4 @@ app.registerExtension({
const context_predicate = () => ComfyApp.clipspace && ComfyApp.clipspace.imgs && ComfyApp.clipspace.imgs.length > 0
ClipspaceDialog.registerButton("MaskEditor", context_predicate, ComfyApp.open_maskeditor);
}
});
});
6 changes: 5 additions & 1 deletion web/scripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ export class ComfyApp {
return "";
}

getRandParam() {
return "&rand=" + Math.random();
}

static isImageNode(node) {
return node.imgs || (node && node.widgets && node.widgets.findIndex(obj => obj.name === 'image') >= 0);
}
Expand Down Expand Up @@ -427,7 +431,7 @@ export class ComfyApp {
this.images = output.images;
imagesChanged = true;
imgURLs = imgURLs.concat(output.images.map(params => {
return api.apiURL("/view?" + new URLSearchParams(params).toString() + app.getPreviewFormatParam());
return api.apiURL("/view?" + new URLSearchParams(params).toString() + app.getPreviewFormatParam() + app.getRandParam());
}))
}
}
Expand Down
2 changes: 1 addition & 1 deletion web/scripts/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ export const ComfyWidgets = {
subfolder = name.substring(0, folder_separator);
name = name.substring(folder_separator + 1);
}
img.src = api.apiURL(`/view?filename=${encodeURIComponent(name)}&type=input&subfolder=${subfolder}${app.getPreviewFormatParam()}`);
img.src = api.apiURL(`/view?filename=${encodeURIComponent(name)}&type=input&subfolder=${subfolder}${app.getPreviewFormatParam()}${app.getRandParam()}`);
node.setSizeForImage?.();
}

Expand Down

0 comments on commit 006b24c

Please sign in to comment.