Fixed components to reload watchlist

This commit is contained in:
2024-09-07 21:13:15 -04:00
parent 5915bb28b8
commit 908325628f
13 changed files with 110 additions and 102 deletions

View File

@ -0,0 +1,31 @@
<script lang="ts" context="module">
import {CheckIfAniListLoggedIn, GetAniListLoggedInUser, GetAniListUserWatchingList} from "../../wailsjs/go/main/App";
import {MediaListSort} from "../anilist/types/AniListTypes";
import { aniListUser, watchListPage, animePerPage, aniListPrimary, aniListLoggedIn, aniListWatchlist } from "./GlobalVariablesAndHelperFunctions.svelte"
let isAniListPrimary: boolean
let page: number
let perPage: number
aniListPrimary.subscribe(value => isAniListPrimary = value)
watchListPage.subscribe(value => page = value)
animePerPage.subscribe(value => perPage = value)
export const CheckIfAniListLoggedInAndLoadWatchList = async () => {
await CheckIfAniListLoggedIn().then(loggedIn => {
if (loggedIn) {
GetAniListLoggedInUser().then(user => {
aniListUser.set(user)
if (isAniListPrimary) {
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
aniListWatchlist.set(watchList)
aniListLoggedIn.set(loggedIn)
})
} else {
aniListLoggedIn.set(loggedIn)
}
})
}
})
}
</script>