mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-20 22:55:59 +00:00
open favorites on startup
This commit is contained in:
29
packages/web/src/utility/OpenTabsOnStartup.svelte
Normal file
29
packages/web/src/utility/OpenTabsOnStartup.svelte
Normal file
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import { openFavorite } from '../appobj/FavoriteFileAppObject.svelte';
|
||||
import { openedTabs } from '../stores';
|
||||
|
||||
import { useFavorites } from './metadataLoaders';
|
||||
|
||||
$: favorites = useFavorites();
|
||||
let opened = false;
|
||||
|
||||
onMount(() => {
|
||||
openOnStartup($favorites);
|
||||
});
|
||||
|
||||
$: openOnStartup($favorites);
|
||||
|
||||
function openOnStartup(list) {
|
||||
if (!list) return;
|
||||
if (opened) return;
|
||||
|
||||
opened = true;
|
||||
|
||||
if ($openedTabs.find(x => !x.closedTime)) return;
|
||||
|
||||
for (const favorite of list.filter(x => x.openOnStartup)) {
|
||||
openFavorite(favorite);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user