Fixed a bug that occurred when working on workflows in more than one browser tab.

This commit is contained in:
TomoyukiMizuma 2023-08-23 22:22:52 +09:00
parent c8a62ca716
commit 46db5de0f4
2 changed files with 14 additions and 4 deletions

View File

@ -1108,7 +1108,11 @@ export class ComfyApp {
}
// Save current workflow automatically
setInterval(() => localStorage.setItem("workflow", JSON.stringify(this.graph.serialize())), 1000);
setInterval(() => {
if (document.visibilityState === "visible") {
localStorage.setItem("workflow", JSON.stringify(this.graph.serialize()));
}
}, 1000);
this.#addDrawNodeHandler();
this.#addDrawGroupsHandler();

View File

@ -777,6 +777,13 @@ export class ComfyUI {
]);
this.is_launchTiming = true;
this.switch_workflow_combo = document.getElementById("comfy-switch-workflow-combo");
document.addEventListener("visibilitychange", () => {
if (document.visibilityState === "visible") {
localStorage.setItem("workflow_current_id", this.switch_workflow_combo.selectedIndex);
}
});
const id_renameWorkflow = "Comfy.RenameWorkflowDialog";
const renameWorkflow = this.settings.addSetting({
id: id_renameWorkflow,
@ -839,11 +846,10 @@ export class ComfyUI {
}
if (this.is_launchTiming && typeof app != "undefined") {
const switch_workflow_combo = document.getElementById("comfy-switch-workflow-combo");
switch_workflow_combo.selectedIndex = app.workflow_current_id;
this.switch_workflow_combo.selectedIndex = app.workflow_current_id;
const workflow_names = app.getWorkflowNames();
const options = switch_workflow_combo.options;
const options = this.switch_workflow_combo.options;
console.assert(options.length === workflow_names.length, "workflow_count != the count of $el(option ~ )");