Skip to content

Commit 6a0eb1c

Browse files
naman-brunohelloanoop
authored andcommitted
fix: nonReplaceableTabTypes getting duplicate
1 parent 4a613ed commit 6a0eb1c

File tree

1 file changed

+20
-7
lines changed
  • packages/bruno-app/src/providers/ReduxStore/slices

1 file changed

+20
-7
lines changed

packages/bruno-app/src/providers/ReduxStore/slices/tabs.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,24 +11,35 @@ const initialState = {
1111
activeTabUid: null
1212
};
1313

14+
const tabTypeAlreadyExists = (tabs, collectionUid, type) => {
15+
return find(tabs, (tab) => tab.collectionUid === collectionUid && tab.type === type);
16+
};
17+
1418
export const tabsSlice = createSlice({
1519
name: 'tabs',
1620
initialState,
1721
reducers: {
1822
addTab: (state, action) => {
1923
const { uid, collectionUid, type, requestPaneTab, preview } = action.payload;
24+
const nonReplaceableTabTypes = [
25+
"variables",
26+
"collection-runner",
27+
"security-settings",
28+
];
2029

2130
const existingTab = find(state.tabs, (tab) => tab.uid === uid);
22-
2331
if (existingTab) {
2432
state.activeTabUid = existingTab.uid;
2533
return;
2634
}
27-
const nonReplaceableTabTypes = [
28-
"variables",
29-
"collection-runner",
30-
"security-settings",
31-
];
35+
36+
if (nonReplaceableTabTypes.includes(type)) {
37+
const existingTab = tabTypeAlreadyExists(state.tabs, collectionUid, type);
38+
if (existingTab) {
39+
state.activeTabUid = existingTab.uid;
40+
return;
41+
}
42+
}
3243

3344
const lastTab = state.tabs[state.tabs.length - 1];
3445
if (state.tabs.length > 0 && lastTab.preview) {
@@ -39,7 +50,9 @@ export const tabsSlice = createSlice({
3950
requestPaneTab: requestPaneTab || 'params',
4051
responsePaneTab: 'response',
4152
type: type || 'request',
42-
preview: true,
53+
preview: preview !== undefined
54+
? preview
55+
: !nonReplaceableTabTypes.includes(type),
4356
...(uid ? { folderUid: uid } : {})
4457
}
4558

0 commit comments

Comments
 (0)