2024-07-09 10:16:53 -04:00
|
|
|
<script lang="ts">
|
2024-08-09 15:14:39 -04:00
|
|
|
import {
|
|
|
|
aniListLoggedIn,
|
2024-08-11 20:27:58 -04:00
|
|
|
aniListPrimary,
|
2024-08-11 21:13:22 -04:00
|
|
|
aniListUser,
|
2024-08-11 20:27:58 -04:00
|
|
|
aniListWatchlist,
|
2024-08-18 17:23:09 -04:00
|
|
|
animePerPage,
|
|
|
|
malLoggedIn,
|
|
|
|
malPrimary,
|
|
|
|
malUser,
|
|
|
|
malWatchList,
|
2024-08-11 21:13:22 -04:00
|
|
|
simklLoggedIn,
|
|
|
|
simklUser,
|
|
|
|
simklWatchList,
|
2024-08-13 19:36:39 -04:00
|
|
|
watchListPage,
|
2024-08-18 17:23:09 -04:00
|
|
|
simklPrimary,
|
2024-09-04 12:05:41 -04:00
|
|
|
aniListAnime,
|
|
|
|
GetAniListSingleItem,
|
|
|
|
} from "./helperComponents/GlobalVariablesAndHelperFunctions.svelte";
|
2024-07-30 20:37:44 -04:00
|
|
|
import {
|
|
|
|
CheckIfAniListLoggedIn,
|
2024-08-13 18:54:27 -04:00
|
|
|
CheckIfMyAnimeListLoggedIn,
|
2024-08-18 17:23:09 -04:00
|
|
|
CheckIfSimklLoggedIn,
|
2024-07-30 20:37:44 -04:00
|
|
|
GetAniListLoggedInUser,
|
|
|
|
GetAniListUserWatchingList,
|
2024-08-18 17:23:09 -04:00
|
|
|
GetMyAnimeList,
|
|
|
|
GetMyAnimeListLoggedInUser,
|
2024-07-31 19:33:04 -04:00
|
|
|
GetSimklLoggedInUser,
|
|
|
|
SimklGetUserWatchlist,
|
2024-07-30 20:37:44 -04:00
|
|
|
} from "../wailsjs/go/main/App";
|
2024-08-11 20:42:57 -04:00
|
|
|
import {MediaListSort} from "./anilist/types/AniListTypes";
|
2024-07-30 20:37:44 -04:00
|
|
|
import {onMount} from "svelte";
|
2024-09-04 12:05:41 -04:00
|
|
|
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 Anime from "./routes/Anime.svelte";
|
|
|
|
import Header from "./helperComponents/Header.svelte";
|
2024-07-24 09:17:39 -04:00
|
|
|
|
2024-08-11 20:27:58 -04:00
|
|
|
|
|
|
|
let isAniListPrimary: boolean
|
2024-08-16 15:07:06 -04:00
|
|
|
let isMalPrimary: boolean
|
2024-08-18 17:23:09 -04:00
|
|
|
let isSimklPrimary: boolean
|
2024-08-09 15:14:39 -04:00
|
|
|
|
2024-08-11 20:27:58 -04:00
|
|
|
aniListPrimary.subscribe((value) => isAniListPrimary = value)
|
2024-08-16 15:07:06 -04:00
|
|
|
malPrimary.subscribe((value) => isMalPrimary = value)
|
2024-08-18 17:23:09 -04:00
|
|
|
simklPrimary.subscribe(value => isSimklPrimary = value)
|
2024-08-11 20:27:58 -04:00
|
|
|
|
2024-08-09 15:14:39 -04:00
|
|
|
|
2024-08-13 19:36:39 -04:00
|
|
|
let page: number
|
|
|
|
let perPage: number
|
|
|
|
watchListPage.subscribe(value => page = value)
|
|
|
|
animePerPage.subscribe(value => perPage = value)
|
2024-07-25 20:02:15 -04:00
|
|
|
|
2024-07-30 20:37:44 -04:00
|
|
|
onMount(async () => {
|
2024-08-15 21:27:31 -04:00
|
|
|
await CheckIfAniListLoggedIn().then(loggedIn => {
|
|
|
|
if (loggedIn) {
|
|
|
|
GetAniListLoggedInUser().then(user => {
|
|
|
|
aniListUser.set(user)
|
2024-08-11 20:27:58 -04:00
|
|
|
if (isAniListPrimary) {
|
2024-08-15 21:27:31 -04:00
|
|
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
|
|
|
|
aniListWatchlist.set(watchList)
|
|
|
|
aniListLoggedIn.set(loggedIn)
|
2024-07-30 20:37:44 -04:00
|
|
|
})
|
|
|
|
} else {
|
2024-08-15 21:27:31 -04:00
|
|
|
aniListLoggedIn.set(loggedIn)
|
2024-07-30 20:37:44 -04:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-08-15 21:27:31 -04:00
|
|
|
await CheckIfMyAnimeListLoggedIn().then(loggedIn => {
|
|
|
|
if (loggedIn) {
|
|
|
|
GetMyAnimeListLoggedInUser().then(user => {
|
|
|
|
malUser.set(user)
|
2024-08-18 17:23:09 -04:00
|
|
|
if (isMalPrimary) {
|
2024-08-16 15:07:06 -04:00
|
|
|
GetMyAnimeList(1000).then(watchList => {
|
|
|
|
malWatchList.set(watchList)
|
|
|
|
malLoggedIn.set(loggedIn)
|
|
|
|
})
|
|
|
|
} else {
|
2024-08-15 21:27:31 -04:00
|
|
|
malLoggedIn.set(loggedIn)
|
2024-08-16 15:07:06 -04:00
|
|
|
}
|
2024-08-13 18:54:27 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-08-15 21:27:31 -04:00
|
|
|
await CheckIfSimklLoggedIn().then(loggedIn => {
|
|
|
|
if (loggedIn) {
|
|
|
|
GetSimklLoggedInUser().then(user => {
|
2024-08-18 17:23:09 -04:00
|
|
|
if (Object.keys(user).length === 0) {
|
|
|
|
simklLoggedIn.set(false)
|
|
|
|
} else {
|
|
|
|
simklUser.set(user)
|
|
|
|
if(isSimklPrimary) {
|
|
|
|
SimklGetUserWatchlist().then(result => {
|
|
|
|
simklWatchList.set(result)
|
|
|
|
simklLoggedIn.set(loggedIn)
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
simklLoggedIn.set(loggedIn)
|
|
|
|
}
|
|
|
|
}
|
2024-07-30 20:37:44 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
2024-07-09 10:16:53 -04:00
|
|
|
</script>
|
|
|
|
|
2024-09-04 12:05:41 -04:00
|
|
|
<Header />
|
|
|
|
<Router routes={{
|
|
|
|
'/': Home,
|
|
|
|
'/anime/:id': wrap({
|
|
|
|
component: Anime,
|
|
|
|
conditions: [
|
|
|
|
async (detail) => {
|
|
|
|
await GetAniListSingleItem(Number(detail.params.id), true)
|
|
|
|
return Object.keys($aniListAnime).length!==0
|
|
|
|
},
|
|
|
|
],
|
|
|
|
loadingComponent: Spinner
|
|
|
|
}),
|
|
|
|
// '*': "Not Found"
|
|
|
|
}} />
|