anitrack/frontend/src/App.svelte

40 lines
1.4 KiB
Svelte
Raw Normal View History

2024-07-09 10:16:53 -04:00
<script lang="ts">
import {
aniListLoggedIn,
aniListAnime,
GetAniListSingleItem,
2024-09-07 21:13:15 -04:00
} from "./helperModules/GlobalVariablesAndHelperFunctions.svelte";
import {onMount} from "svelte";
import Router from "svelte-spa-router"
import Home from "./routes/Home.svelte";
import {wrap} from "svelte-spa-router/wrap";
import Spinner from "./helperComponents/Spinner.svelte";
import Header from "./helperComponents/Header.svelte";
2024-09-07 21:13:15 -04:00
import {CheckIfAniListLoggedInAndLoadWatchList} from "./helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
import { CheckIfMALLoggedInAndSetUser } from "./helperModules/CheckIfMyAnimeListLoggedIn.svelte";
import {CheckIfSimklLoggedInAndSetUser} from "./helperModules/CheckIsSimklLoggedIn.svelte"
onMount(async () => {
2024-09-07 21:13:15 -04:00
await CheckIfAniListLoggedInAndLoadWatchList()
await CheckIfMALLoggedInAndSetUser()
await CheckIfSimklLoggedInAndSetUser()
})
2024-07-09 10:16:53 -04:00
</script>
<Header />
<Router routes={{
'/': Home,
'/anime/:id': wrap({
2024-09-04 12:26:26 -04:00
asyncComponent: () => import('./routes/Anime.svelte'),
conditions: [
() => $aniListLoggedIn,
async (detail) => {
await GetAniListSingleItem(Number(detail.params.id), true)
return Object.keys($aniListAnime).length!==0
},
],
loadingComponent: Spinner
}),
// '*': "Not Found"
}} />