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

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