From 5cb4d24708be90d03188c61403bfad3dbbde0e52 Mon Sep 17 00:00:00 2001 From: broisnees Date: Tue, 17 Nov 2026 02:37:31 +0000 Subject: [PATCH] Close the other open databases when several connections is turned off --- src/lib/components/SettingsDialog.svelte | 4 +++- src/lib/components/StudioShell.svelte | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/lib/components/SettingsDialog.svelte b/src/lib/components/SettingsDialog.svelte index a695b41f..56913dca 100644 --- a/src/lib/components/SettingsDialog.svelte +++ b/src/lib/components/SettingsDialog.svelte @@ -792,7 +792,9 @@ settings.multiConnection === true, () => { settings = updateSettings({ multiConnection: settings.multiConnection !== true }); - if (!settings.multiConnection) void import('@tauri-apps/api/core').then(({ invoke }) => invoke('close_parked', { key: null })).catch(() => {}); + // The shell closes the kept databases and drops them from the tab bar + // and the status bar; only it knows which ones are open. + if (!settings.multiConnection) window.dispatchEvent(new CustomEvent('stroke:multi-connection-off')); }, )} {/if} diff --git a/src/lib/components/StudioShell.svelte b/src/lib/components/StudioShell.svelte index b1ce74b8..c5a6d6dc 100644 --- a/src/lib/components/StudioShell.svelte +++ b/src/lib/components/StudioShell.svelte @@ -8370,7 +8370,8 @@ let rowSearch = $state('') } /** Labs: close every open database at once (the dialog's Disconnect all). */ - async function handleDisconnectAll() { + /** Close every kept database; the one on screen stays. */ + async function closeKeptSessions() { try { const { invoke } = await import('@tauri-apps/api/core') await invoke('close_parked', { key: null, connection: null }) @@ -8378,9 +8379,21 @@ let rowSearch = $state('') _sessions.clear() sessionOrder = [] sessionsTick++ + } + + async function handleDisconnectAll() { + await closeKeptSessions() await handleDisconnect() } + // Labs turned off in Settings: the other open databases close, so the tab + // bar and the status bar go back to the one connection on screen. + $effect(() => { + const on = () => { void closeKeptSessions() } + window.addEventListener('stroke:multi-connection-off', on) + return () => window.removeEventListener('stroke:multi-connection-off', on) + }) + /** * A saved connection was deleted (sidebar or connection modal). Deleting the * one that is open also ends its session: staying connected to a connection