chore(web): migration svelte 5 syntax (#13883)

This commit is contained in:
Alex
2024-11-14 08:43:25 -06:00
committed by GitHub
parent 9203a61709
commit 0b3742cf13
310 changed files with 6435 additions and 4176 deletions

View File

@@ -36,32 +36,36 @@
import ButtonContextMenu from '$lib/components/shared-components/context-menu/button-context-menu.svelte';
import { locale } from '$lib/stores/preferences.store';
export let data: PageData;
interface Props {
data: PageData;
}
let libraries: LibraryResponseDto[] = [];
let { data }: Props = $props();
let libraries: LibraryResponseDto[] = $state([]);
let stats: LibraryStatsResponseDto[] = [];
let owner: UserResponseDto[] = [];
let owner: UserResponseDto[] = $state([]);
let photos: number[] = [];
let videos: number[] = [];
let totalCount: number[] = [];
let diskUsage: number[] = [];
let diskUsageUnit: ByteUnit[] = [];
let editImportPaths: number | null;
let editScanSettings: number | null;
let renameLibrary: number | null;
let totalCount: number[] = $state([]);
let diskUsage: number[] = $state([]);
let diskUsageUnit: ByteUnit[] = $state([]);
let editImportPaths: number | undefined = $state();
let editScanSettings: number | undefined = $state();
let renameLibrary: number | undefined = $state();
let updateLibraryIndex: number | null;
let dropdownOpen: boolean[] = [];
let toCreateLibrary = false;
let toCreateLibrary = $state(false);
onMount(async () => {
await readLibraryList();
});
const closeAll = () => {
editImportPaths = null;
editScanSettings = null;
renameLibrary = null;
editImportPaths = undefined;
editScanSettings = undefined;
renameLibrary = undefined;
updateLibraryIndex = null;
for (let index = 0; index < dropdownOpen.length; index++) {
@@ -213,22 +217,24 @@
{/if}
<UserPageLayout title={data.meta.title} admin>
<div class="flex justify-end gap-2" slot="buttons">
{#if libraries.length > 0}
<LinkButton on:click={() => handleScanAll()}>
{#snippet buttons()}
<div class="flex justify-end gap-2">
{#if libraries.length > 0}
<LinkButton onclick={() => handleScanAll()}>
<div class="flex gap-1 text-sm">
<Icon path={mdiSync} size="18" />
<span>{$t('scan_all_libraries')}</span>
</div>
</LinkButton>
{/if}
<LinkButton onclick={() => (toCreateLibrary = true)}>
<div class="flex gap-1 text-sm">
<Icon path={mdiSync} size="18" />
<span>{$t('scan_all_libraries')}</span>
<Icon path={mdiPlusBoxOutline} size="18" />
<span>{$t('create_library')}</span>
</div>
</LinkButton>
{/if}
<LinkButton on:click={() => (toCreateLibrary = true)}>
<div class="flex gap-1 text-sm">
<Icon path={mdiPlusBoxOutline} size="18" />
<span>{$t('create_library')}</span>
</div>
</LinkButton>
</div>
</div>
{/snippet}
<section class="my-4">
<div class="flex flex-col gap-2" in:fade={{ duration: 500 }}>
{#if libraries.length > 0}
@@ -311,13 +317,17 @@
{#if renameLibrary === index}
<!-- svelte-ignore node_invalid_placement_ssr -->
<div transition:slide={{ duration: 250 }}>
<LibraryRenameForm {library} onSubmit={handleUpdate} onCancel={() => (renameLibrary = null)} />
<LibraryRenameForm {library} onSubmit={handleUpdate} onCancel={() => (renameLibrary = undefined)} />
</div>
{/if}
{#if editImportPaths === index}
<!-- svelte-ignore node_invalid_placement_ssr -->
<div transition:slide={{ duration: 250 }}>
<LibraryImportPathsForm {library} onSubmit={handleUpdate} onCancel={() => (editImportPaths = null)} />
<LibraryImportPathsForm
{library}
onSubmit={handleUpdate}
onCancel={() => (editImportPaths = undefined)}
/>
</div>
{/if}
{#if editScanSettings === index}
@@ -326,7 +336,7 @@
<LibraryScanSettingsForm
{library}
onSubmit={handleUpdate}
onCancel={() => (editScanSettings = null)}
onCancel={() => (editScanSettings = undefined)}
/>
</div>
{/if}