1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-01-10 05:46:46 +01:00
immich/web/src/routes/+layout.svelte
Alex 1918625be9
fix(web): nested layout navigation issue (#1936)
* fix(web): nested layout navigation issue

* move guarding to html template

* fix test
2023-03-04 16:09:55 -06:00

78 lines
2.5 KiB
Svelte

<script lang="ts">
import '../app.css';
import { page } from '$app/stores';
import { afterNavigate, beforeNavigate } from '$app/navigation';
import NavigationLoadingBar from '$lib/components/shared-components/navigation-loading-bar.svelte';
import DownloadPanel from '$lib/components/asset-viewer/download-panel.svelte';
import UploadPanel from '$lib/components/shared-components/upload-panel.svelte';
import NotificationList from '$lib/components/shared-components/notification/notification-list.svelte';
import VersionAnnouncementBox from '$lib/components/shared-components/version-announcement-box.svelte';
import faviconUrl from '$lib/assets/favicon.png';
import type { LayoutData } from './$types';
import { fileUploadHandler } from '$lib/utils/file-uploader';
import UploadCover from '$lib/components/shared-components/drag-and-drop-upload-overlay.svelte';
let showNavigationLoadingBar = false;
export let data: LayoutData;
beforeNavigate(() => {
showNavigationLoadingBar = true;
});
afterNavigate(() => {
showNavigationLoadingBar = false;
});
const dropHandler = async ({ dataTransfer }: DragEvent) => {
const files = dataTransfer?.files;
if (!files) {
return;
}
const filesArray: File[] = Array.from<File>(files);
const albumId =
($page.route.id === '/(user)/albums/[albumId]' || undefined) && $page.params.albumId;
await fileUploadHandler(filesArray, albumId);
};
</script>
<svelte:head>
<title>{$page.data.meta?.title || 'Web'} - Immich</title>
<link rel="icon" href={faviconUrl} />
{#if $page.data.meta}
<meta name="description" content={$page.data.meta.description} />
<!-- Facebook Meta Tags -->
<meta property="og:type" content="website" />
<meta property="og:title" content={$page.data.meta.title} />
<meta property="og:description" content={$page.data.meta.description} />
<meta property="og:image" content={$page.data.meta.imageUrl} />
<!-- Twitter Meta Tags -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content={$page.data.meta.title} />
<meta name="twitter:description" content={$page.data.meta.description} />
<meta name="twitter:image" content={$page.data.meta.imageUrl} />
{/if}
</svelte:head>
{#if showNavigationLoadingBar}
<NavigationLoadingBar />
{/if}
<slot />
<DownloadPanel />
<UploadPanel />
<NotificationList />
{#if data.user?.isAdmin}
<VersionAnnouncementBox serverVersion={data.serverVersion} />
{/if}
{#if $page.route.id?.includes('(user)')}
<UploadCover {dropHandler} />
{/if}