<script lang="ts">
    import { aniListAnime, GetAnimeSingleItem } from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
    import Anime from "../helperComponents/Anime.svelte"
    import { AniListGetSingleAnimeDefaultData } from "../helperDefaults/AniListGetSingleAnime";
    import Spinner from "../helperComponents/Spinner.svelte";

    export let params: Record<string, string>
    let loadPromise = load(params.id)
    $: loadPromise = load(params.id)

    async function load(id: string) {
        aniListAnime.update(() => AniListGetSingleAnimeDefaultData)
        await GetAnimeSingleItem(Number(id), true)
    }
</script>

{#key params.id}
    {#await loadPromise}
        <Spinner />
    {:then _}
        <Anime />
    {/await}
{/key}