From 80e95447635d8d57dfba092fb9106beea519b5f9 Mon Sep 17 00:00:00 2001 From: TomoyukiMizuma Date: Wed, 23 Aug 2023 23:35:55 +0900 Subject: [PATCH] Fixed a bug that occurred when working on workflows in more than one window. --- web/scripts/app.js | 2 +- web/scripts/ui.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/web/scripts/app.js b/web/scripts/app.js index b980e2882..3cbd8eb9a 100644 --- a/web/scripts/app.js +++ b/web/scripts/app.js @@ -1109,7 +1109,7 @@ export class ComfyApp { // Save current workflow automatically setInterval(() => { - if (document.visibilityState === "visible") { + if (document.hasFocus()) { localStorage.setItem("workflow", JSON.stringify(this.graph.serialize())); } }, 1000); diff --git a/web/scripts/ui.js b/web/scripts/ui.js index 33aed7e72..68de5a67d 100644 --- a/web/scripts/ui.js +++ b/web/scripts/ui.js @@ -778,10 +778,8 @@ 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); - } + window.addEventListener("focus", () => { + localStorage.setItem("workflow_current_id", this.switch_workflow_combo.selectedIndex); }); const id_renameWorkflow = "Comfy.RenameWorkflowDialog";