1
0
mirror of https://github.com/immich-app/immich.git synced 2024-11-24 08:52:28 +02:00

chore: cleanup layout setup (#6995)

This commit is contained in:
Ben McCann 2024-02-09 08:16:59 -08:00 committed by GitHub
parent 9d072b5f55
commit e4561f26e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 24 deletions

View File

@ -0,0 +1,29 @@
<script lang="ts">
import { page } from '$app/stores';
import UploadCover from '$lib/components/shared-components/drag-and-drop-upload-overlay.svelte';
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
import { fileUploadHandler } from '$lib/utils/file-uploader';
let albumId: string | undefined;
const dropHandler = async ({ dataTransfer }: DragEvent) => {
const files = dataTransfer?.files;
if (!files) {
return;
}
const filesArray: File[] = Array.from<File>(files);
albumId = ($page.route.id === '/(user)/albums/[albumId]' || undefined) && $page.params.albumId;
const isShare = $page.route.id === '/(user)/share/[key]' || undefined;
if (isShare) {
dragAndDropFilesStore.set({ isDragging: true, files: filesArray });
} else {
await fileUploadHandler(filesArray, albumId);
}
};
</script>
<slot {albumId} />
<UploadCover {dropHandler} />

View File

@ -7,14 +7,11 @@
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 { fileUploadHandler } from '$lib/utils/file-uploader';
import UploadCover from '$lib/components/shared-components/drag-and-drop-upload-overlay.svelte';
import FullscreenContainer from '$lib/components/shared-components/fullscreen-container.svelte';
import AppleHeader from '$lib/components/shared-components/apple-header.svelte';
import { onDestroy, onMount } from 'svelte';
import { loadConfig } from '$lib/stores/server-config.store';
import { handleError } from '$lib/utils/handle-error';
import { dragAndDropFilesStore } from '$lib/stores/drag-and-drop-files.store';
import { api } from '@api';
import { closeWebsocketConnection, openWebsocketConnection } from '$lib/stores/websocket';
import { user } from '$lib/stores/user.store';
@ -91,23 +88,6 @@
handleError(error, 'Unable to connect to server');
}
});
const dropHandler = async ({ dataTransfer }: DragEvent) => {
const files = dataTransfer?.files;
if (!files) {
return;
}
const filesArray: File[] = Array.from<File>(files);
albumId = ($page.route.id === '/(user)/albums/[albumId]' || undefined) && $page.params.albumId;
const isShare = $page.route.id === '/(user)/share/[key]' || undefined;
if (isShare) {
dragAndDropFilesStore.set({ isDragging: true, files: filesArray });
} else {
await fileUploadHandler(filesArray, albumId);
}
};
</script>
<svelte:head>
@ -154,7 +134,3 @@
{#if $user?.isAdmin}
<VersionAnnouncementBox />
{/if}
{#if $page.route.id?.includes('(user)')}
<UploadCover {dropHandler} />
{/if}