From 1d7abdd8303fd9e7c16a8e7140d4f130b3bb8c73 Mon Sep 17 00:00:00 2001 From: Sajal Jain Date: Sat, 13 Jul 2024 19:29:25 -0700 Subject: [PATCH 1/2] fix file system to ide updates for env and flowtest tabs --- packages/flowtest-electron/src/app/watcher.js | 5 ++++- src/stores/CollectionStore.js | 10 +++++----- src/stores/TabStore.js | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/packages/flowtest-electron/src/app/watcher.js b/packages/flowtest-electron/src/app/watcher.js index 6730aea..754d75a 100644 --- a/packages/flowtest-electron/src/app/watcher.js +++ b/packages/flowtest-electron/src/app/watcher.js @@ -92,9 +92,12 @@ class Watcher { change(mainWindow, pathname, collectionId, watchPath) { console.log(`[Watcher] file ${pathname} changed`); if (this.isFlowTestFile(pathname)) { + const content = readFile(pathname); + const flowData = serialize(JSON.parse(content)); const file = { name: path.basename(pathname), - pathname: pathname, + pathname, + flowData, }; mainWindow.webContents.send('main:update-flowtest', file, collectionId); } else if (this.isEnvFile(pathname, watchPath)) { diff --git a/src/stores/CollectionStore.js b/src/stores/CollectionStore.js index 304ef5b..4f66522 100644 --- a/src/stores/CollectionStore.js +++ b/src/stores/CollectionStore.js @@ -117,8 +117,8 @@ const useCollectionStore = create((set, get) => ({ // check if there are any open tabs, if yes mark them saved const tab = useTabStore.getState().tabs.find((t) => t.id === existingEnv.id); - if (tab && tab.variablesDraft) { - tab.variables = cloneDeep(tab.variablesDraft); + if (tab) { + tab.variables = file.variables; tab.variablesDraft = null; } } else { @@ -286,9 +286,9 @@ const useCollectionStore = create((set, get) => ({ // console.log(`Collection updated: ${JSON.stringify(collection)}`); // check if there are any open tabs, if yes mark them saved - const tab = useTabStore.getState().tabs.find((t) => t.id === item.id); - if (tab && tab.flowDataDraft) { - useTabStore.getState().saveFlowTestTab(tab); + const existingTab = useTabStore.getState().tabs.find((t) => t.id === item.id); + if (existingTab) { + useTabStore.getState().saveFlowTestTab(existingTab, cloneDeep(file.flowData)); } } } diff --git a/src/stores/TabStore.js b/src/stores/TabStore.js index ba68b0b..243c98d 100644 --- a/src/stores/TabStore.js +++ b/src/stores/TabStore.js @@ -33,7 +33,7 @@ export const useTabStore = create((set, get) => ({ set((state) => ({ tabs: [...state.tabs, newTab] })); set(() => ({ focusTabId: newTab.id })); }, - saveFlowTestTab: (tab) => { + saveFlowTestTab: (tab, updatedFlowData) => { set( produce((state) => { const existingTab = state.tabs.find( @@ -45,7 +45,7 @@ export const useTabStore = create((set, get) => ({ tab.type === OBJ_TYPES.flowtest, ); if (existingTab) { - existingTab.flowData = cloneDeep(existingTab.flowDataDraft); + existingTab.flowData = updatedFlowData; existingTab.flowDataDraft = null; } }), From d66093df9e025c3c8be1e3224e4b5f35ef44c9df Mon Sep 17 00:00:00 2001 From: Sajal Jain Date: Sat, 13 Jul 2024 19:30:28 -0700 Subject: [PATCH 2/2] fix file system to ide updates for env and flowtest tabs --- src/stores/CollectionStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/stores/CollectionStore.js b/src/stores/CollectionStore.js index 4f66522..db1aed9 100644 --- a/src/stores/CollectionStore.js +++ b/src/stores/CollectionStore.js @@ -118,7 +118,7 @@ const useCollectionStore = create((set, get) => ({ // check if there are any open tabs, if yes mark them saved const tab = useTabStore.getState().tabs.find((t) => t.id === existingEnv.id); if (tab) { - tab.variables = file.variables; + tab.variables = cloneDeep(file.variables); tab.variablesDraft = null; } } else {