From a84080b48247c39cd1280bce1bf4023a936b22fb Mon Sep 17 00:00:00 2001 From: Anoop M D Date: Sat, 15 Oct 2022 01:45:15 +0530 Subject: [PATCH] fix: activeTabUid was not being reset to null --- .../src/providers/ReduxStore/slices/tabs.js | 32 ++++--------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js b/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js index c34d9268d..91b6e7d60 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/tabs.js @@ -15,6 +15,10 @@ export const tabsSlice = createSlice({ initialState, reducers: { addTab: (state, action) => { + const alreadyExists = find(state.tabs, (tab) => tab.uid === action.payload.uid); + if(alreadyExists) { + return; + } state.tabs.push({ uid: action.payload.uid, collectionUid: action.payload.collectionUid, @@ -68,32 +72,9 @@ export const tabsSlice = createSlice({ } } } - }, - // todo: implement this - // the refreshTabs us currently not beng used - // the goal is to have the main page listen to unlink events and - // remove tabs which are no longer valid - refreshTabs: (state, action) => { - // remove all tabs that we don't have itemUids in all loaded collections - const allItemUids = action.payload.allItemUids || []; - state.tabs = filter(state.tabs, (tab) => { - return allItemUids.includes(tab.uid); - }); - // adjust the activeTabUid - const collectionUid = action.payload.activeCollectionUid; - const collectionTabs = filter(state.tabs, (t) => t.collectionUid === collectionUid); - - if(!collectionTabs || !collectionTabs.length) { + if(!state.tabs || !state.tabs.length) { state.activeTabUid = null; - return; - } - - const activeTabStillExists = find(state.tabs, (t) => t.uid === state.activeTabUid); - - if(!activeTabStillExists) { - // todo: closing tab needs to focus on the right adjacent tab - state.activeTabUid = last(collectionTabs).uid; } } } @@ -105,8 +86,7 @@ export const { updateRequestPaneTabWidth, updateRequestPaneTab, updateResponsePaneTab, - closeTabs, - refreshTabs + closeTabs } = tabsSlice.actions; export default tabsSlice.reducer;