From ec25586a6ec3cb8431c5b792e010530489f7cd8d Mon Sep 17 00:00:00 2001 From: Laurent Nguyen Date: Fri, 6 Dec 2024 17:14:37 +0100 Subject: [PATCH] Close all tabs and always load first container when initializing Fabric (#2014) Co-authored-by: Laurent Nguyen --- src/hooks/useKnockoutExplorer.ts | 3 ++- src/hooks/useTabs.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index 430cef277..605a70e49 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -142,7 +142,7 @@ async function configureFabric(): Promise { await scheduleRefreshDatabaseResourceToken(true); resolve(explorer); await explorer.refreshAllDatabases(); - if (userContext.fabricContext.isVisible && !firstContainerOpened) { + if (userContext.fabricContext.isVisible) { firstContainerOpened = true; openFirstContainer(explorer, userContext.fabricContext.databaseConnectionInfo.databaseId); } @@ -439,6 +439,7 @@ function createExplorerFabric(params: { connectionId: string; isVisible: boolean }, }, }); + useTabs.getState().closeAllTabs(); const explorer = new Explorer(); return explorer; } diff --git a/src/hooks/useTabs.ts b/src/hooks/useTabs.ts index 001dfcf87..16835aeb4 100644 --- a/src/hooks/useTabs.ts +++ b/src/hooks/useTabs.ts @@ -42,6 +42,7 @@ export interface TabsState { selectLeftTab: () => void; selectRightTab: () => void; closeActiveTab: () => void; + closeAllTabs: () => void; persistTabsState: () => void; } @@ -237,6 +238,9 @@ export const useTabs: UseStore = create((set, get) => ({ state.closeTab(state.activeTab); } }, + closeAllTabs: () => { + set({ openedTabs: [], openedReactTabs: [], activeTab: undefined, activeReactTab: undefined }); + }, persistTabsState: () => { const state = get(); const openTabsStates = state.openedTabs.map((tab) => tab.getPersistedState());