fix: fixed screen crash when collection was removed

This commit is contained in:
Anoop M D 2023-09-28 03:26:13 +05:30
parent 665428a2d0
commit 487dd73040
2 changed files with 17 additions and 9 deletions

View File

@ -42,8 +42,8 @@ import {
collectionAddEnvFileEvent as _collectionAddEnvFileEvent
} from './index';
import { closeTabs } from 'providers/ReduxStore/slices/tabs';
import { isLocalCollection, resolveRequestFilename } from 'utils/common/platform';
import { closeAllCollectionTabs } from 'providers/ReduxStore/slices/tabs';
import { resolveRequestFilename } from 'utils/common/platform';
const PATH_SEPARATOR = path.sep;
@ -723,11 +723,7 @@ export const removeCollection = (collectionUid) => (dispatch, getState) => {
ipcRenderer
.invoke('renderer:remove-collection', collection.pathname)
.then(() => {
dispatch(
closeTabs({
tabUids: recursivelyGetAllItemUids(collection.items)
})
);
dispatch(closeAllCollectionTabs({ collectionUid }));
})
.then(waitForNextTick)
.then(() => {

View File

@ -92,11 +92,23 @@ export const tabsSlice = createSlice({
if (!state.tabs || !state.tabs.length) {
state.activeTabUid = null;
}
},
closeAllCollectionTabs: (state, action) => {
const collectionUid = action.payload.collectionUid;
state.tabs = filter(state.tabs, (t) => t.collectionUid !== collectionUid);
state.activeTabUid = null;
}
}
});
export const { addTab, focusTab, updateRequestPaneTabWidth, updateRequestPaneTab, updateResponsePaneTab, closeTabs } =
tabsSlice.actions;
export const {
addTab,
focusTab,
updateRequestPaneTabWidth,
updateRequestPaneTab,
updateResponsePaneTab,
closeTabs,
closeAllCollectionTabs
} = tabsSlice.actions;
export default tabsSlice.reducer;