Skip to content

Commit

Permalink
Merge branch 'image-cache' of https://github.com/jn-jairo/ComfyUI
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Dec 2, 2023
2 parents 28220fa + c92f3dc commit 88e2c97
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 @@ -86,6 +86,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 @@ -437,7 +441,7 @@ export class ComfyApp {
return api.apiURL(
"/view?" +
new URLSearchParams(params).toString() +
(this.animatedImages ? "" : app.getPreviewFormatParam())
(this.animatedImages ? "" : 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 @@ -310,7 +310,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 88e2c97

Please sign in to comment.