mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 23:43:15 +01:00
fix: activeTabUid was not being reset to null
This commit is contained in:
parent
b3bf29d6b2
commit
a84080b482
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user