open favorites on startup

This commit is contained in:
Jan Prochazka 2021-04-01 13:32:44 +02:00
parent acdba0c52c
commit 484e7c27a2
3 changed files with 33 additions and 10 deletions

View File

@ -5,19 +5,11 @@ SERVER_mysql=localhost
USER_mysql=root
PASSWORD_mysql=test
PORT_mysql=3307
ENGINE_mysql=mysql
ENGINE_mysql=mysql@dbgate-plugin-mysql
LABEL_postgres=Postgres localhost
SERVER_postgres=localhost
USER_postgres=postgres
PASSWORD_postgres=test
PORT_postgres=5433
ENGINE_postgres=postgres
TOOLBAR=home
ICON_home=mdi mdi-home
TITLE_home=Home
PAGE_home=home.html
STARTUP_PAGES=home
PAGES_DIRECTORY=/home/jena/jenasoft/dbgate-web/pages
ENGINE_postgres=postgres@dbgate-plugin-postgres

View File

@ -4,9 +4,11 @@
import PluginsProvider from './plugins/PluginsProvider.svelte';
import Screen from './Screen.svelte';
import ErrorHandler from './utility/ErrorHandler.svelte';
import OpenTabsOnStartup from './utility/OpenTabsOnStartup.svelte';
</script>
<ErrorHandler />
<PluginsProvider />
<CommandListener />
<OpenTabsOnStartup />
<Screen />

View 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>