Skip to content

Commit bf4e714

Browse files
committed
fix saving tabs
1 parent da278f9 commit bf4e714

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/stores/CollectionStore.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,7 @@ const useCollectionStore = create((set, get) => ({
288288
// check if there are any open tabs, if yes mark them saved
289289
const tab = useTabStore.getState().tabs.find((t) => t.id === item.id);
290290
if (tab && tab.flowDataDraft) {
291-
tab.flowData = cloneDeep(tab.flowDataDraft);
292-
tab.flowDataDraft = null;
291+
useTabStore.getState().saveFlowTestTab(tab);
293292
}
294293
}
295294
}

src/stores/TabStore.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,24 @@ export const useTabStore = create((set, get) => ({
3333
set((state) => ({ tabs: [...state.tabs, newTab] }));
3434
set(() => ({ focusTabId: newTab.id }));
3535
},
36+
saveFlowTestTab: (tab) => {
37+
set(
38+
produce((state) => {
39+
const existingTab = state.tabs.find(
40+
(t) =>
41+
t.id === tab.id &&
42+
t.name === tab.name &&
43+
t.pathname === tab.pathname &&
44+
t.collectionId === tab.collectionId &&
45+
tab.type === OBJ_TYPES.flowtest,
46+
);
47+
if (existingTab) {
48+
existingTab.flowData = cloneDeep(existingTab.flowDataDraft);
49+
existingTab.flowDataDraft = null;
50+
}
51+
}),
52+
);
53+
},
3654
// these state changes are meant to be triggered by canvas in focus
3755
updateFlowTestNodes: (nodes) => {
3856
set(

0 commit comments

Comments
 (0)