Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/flowtest-electron/src/app/watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
10 changes: 5 additions & 5 deletions src/stores/CollectionStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = cloneDeep(file.variables);
tab.variablesDraft = null;
}
} else {
Expand Down Expand Up @@ -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));
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/TabStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
}
}),
Expand Down