Skip to content

Commit

Permalink
del repeat func
Browse files Browse the repository at this point in the history
  • Loading branch information
CurryYangxx committed Jan 6, 2025
1 parent d38b208 commit 2dc6493
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions packages/insomnia/src/ui/context/app/insomnia-tab-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,38 +120,6 @@ export const InsomniaTabProvider: FC<PropsWithChildren> = ({ children }) => {
uiEventBus.emit(UIEventType.CLOSE_TAB, organizationId, [id]);
}, [navigate, organizationId, projectId, updateInsomniaTabs]);

const batchCloseTabs = useCallback((deleteIds: string[]) => {
const currentTabs = appTabsRef?.current?.[organizationId];
if (!currentTabs) {
return;
}

if (currentTabs.tabList.every(tab => deleteIds.includes(tab.id))) {
navigate(`/organization/${organizationId}/project/${projectId}`);
updateInsomniaTabs({
organizationId,
tabList: [],
activeTabId: '',
});
uiEventBus.emit(UIEventType.CLOSE_TAB, organizationId, 'all');
return;
}

const index = currentTabs.tabList.findIndex(tab => deleteIds.includes(tab.id));
const newTabList = currentTabs.tabList.filter(tab => !deleteIds.includes(tab.id));
if (deleteIds.includes(currentTabs.activeTabId || '')) {
const url = newTabList[Math.max(index - 1, 0)]?.url;
navigate(url);
}

updateInsomniaTabs({
organizationId,
tabList: newTabList,
activeTabId: deleteIds.includes(currentTabs.activeTabId || '') ? newTabList[Math.max(index - 1, 0)]?.id : currentTabs.activeTabId as string,
});
uiEventBus.emit(UIEventType.CLOSE_TAB, organizationId, deleteIds);
}, [navigate, organizationId, projectId, updateInsomniaTabs]);

const batchCloseTabs = useCallback((deleteIds: string[]) => {
const currentTabs = appTabsRef?.current?.[organizationId];
if (!currentTabs) {
Expand Down

0 comments on commit 2dc6493

Please sign in to comment.