From f41c8194fc11da9c76de0531cccd73df78a4b1c2 Mon Sep 17 00:00:00 2001 From: tomasz-io Date: Tue, 11 Mar 2025 11:01:05 -0700 Subject: [PATCH] fix: watcher --- gui/src/pages/gui/ExploreDialogWatcher.tsx | 24 ++++++++++++---------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/gui/src/pages/gui/ExploreDialogWatcher.tsx b/gui/src/pages/gui/ExploreDialogWatcher.tsx index 70233b9ca..51851c0f5 100644 --- a/gui/src/pages/gui/ExploreDialogWatcher.tsx +++ b/gui/src/pages/gui/ExploreDialogWatcher.tsx @@ -1,4 +1,3 @@ -import { useRef } from "react"; import { useWebviewListener } from "../../hooks/useWebviewListener"; import { useAppDispatch } from "../../redux/hooks"; import { setIsExploreDialogOpen } from "../../redux/slices/uiSlice"; @@ -9,20 +8,23 @@ import { } from "../../util/localStorage"; const useTutorialListener = (onTutorialClosed: () => void) => { - const isTutorialOpenRef = useRef(false); + useWebviewListener("didCloseFiles", async (data) => { + const uris = data?.uris ?? []; - useWebviewListener("didChangeActiveTextEditor", async (data) => { - const filepath = data?.filepath?.toLowerCase() ?? ""; - const isTutorial = - filepath.endsWith("continue_tutorial.py") || - filepath.endsWith("continue_tutorial.java") || - filepath.endsWith("continue_tutorial.ts"); + const isTutorial = uris.some((uri) => { + const lowercaseUri = uri.toLowerCase(); + return ( + lowercaseUri.endsWith("continue_tutorial.py") || + lowercaseUri.endsWith("continue_tutorial.java") || + lowercaseUri.endsWith("continue_tutorial.ts") + ); + }); - if (isTutorialOpenRef.current && !isTutorial) { + console.log("IS TUTORIAL", isTutorial, uris); + + if (isTutorial) { onTutorialClosed(); } - - isTutorialOpenRef.current = isTutorial; }); };