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

@@ -1,11 +1,16 @@
<script lang="ts">
import type { PersonResponseDto } from '@immich/sdk';
export let people: PersonResponseDto[];
export let hasNextPage: boolean | undefined = undefined;
export let loadNextPage: () => void;
interface Props {
people: PersonResponseDto[];
hasNextPage?: boolean | undefined;
loadNextPage: () => void;
children?: import('svelte').Snippet<[{ person: PersonResponseDto; index: number }]>;
}
let lastPersonContainer: HTMLElement | undefined;
let { people, hasNextPage = undefined, loadNextPage, children }: Props = $props();
let lastPersonContainer: HTMLElement | undefined = $state();
const intersectionObserver = new IntersectionObserver((entries) => {
const entry = entries.find((entry) => entry.target === lastPersonContainer);
@@ -14,20 +19,22 @@
}
});
$: if (lastPersonContainer) {
intersectionObserver.disconnect();
intersectionObserver.observe(lastPersonContainer);
}
$effect(() => {
if (lastPersonContainer) {
intersectionObserver.disconnect();
intersectionObserver.observe(lastPersonContainer);
}
});
</script>
<div class="w-full grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 xl:grid-cols-7 2xl:grid-cols-9 gap-1">
{#each people as person, index (person.id)}
{#if hasNextPage && index === people.length - 1}
<div bind:this={lastPersonContainer}>
<slot {person} {index} />
{@render children?.({ person, index })}
</div>
{:else}
<slot {person} {index} />
{@render children?.({ person, index })}
{/if}
{/each}
</div>