Fixed components to reload watchlist
This commit is contained in:
@ -1,108 +1,23 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
aniListLoggedIn,
|
||||
aniListPrimary,
|
||||
aniListUser,
|
||||
aniListWatchlist,
|
||||
animePerPage,
|
||||
malLoggedIn,
|
||||
malPrimary,
|
||||
malUser,
|
||||
malWatchList,
|
||||
simklLoggedIn,
|
||||
simklUser,
|
||||
simklWatchList,
|
||||
watchListPage,
|
||||
simklPrimary,
|
||||
aniListAnime,
|
||||
GetAniListSingleItem,
|
||||
} from "./helperComponents/GlobalVariablesAndHelperFunctions.svelte";
|
||||
import {
|
||||
CheckIfAniListLoggedIn,
|
||||
CheckIfMyAnimeListLoggedIn,
|
||||
CheckIfSimklLoggedIn,
|
||||
GetAniListLoggedInUser,
|
||||
GetAniListUserWatchingList,
|
||||
GetMyAnimeList,
|
||||
GetMyAnimeListLoggedInUser,
|
||||
GetSimklLoggedInUser,
|
||||
SimklGetUserWatchlist,
|
||||
} from "../wailsjs/go/main/App";
|
||||
import {MediaListSort} from "./anilist/types/AniListTypes";
|
||||
} 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";
|
||||
|
||||
|
||||
let isAniListPrimary: boolean
|
||||
let isMalPrimary: boolean
|
||||
let isSimklPrimary: boolean
|
||||
|
||||
aniListPrimary.subscribe((value) => isAniListPrimary = value)
|
||||
malPrimary.subscribe((value) => isMalPrimary = value)
|
||||
simklPrimary.subscribe(value => isSimklPrimary = value)
|
||||
|
||||
|
||||
let page: number
|
||||
let perPage: number
|
||||
watchListPage.subscribe(value => page = value)
|
||||
animePerPage.subscribe(value => perPage = value)
|
||||
import {CheckIfAniListLoggedInAndLoadWatchList} from "./helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||
import { CheckIfMALLoggedInAndSetUser } from "./helperModules/CheckIfMyAnimeListLoggedIn.svelte";
|
||||
import {CheckIfSimklLoggedInAndSetUser} from "./helperModules/CheckIsSimklLoggedIn.svelte"
|
||||
|
||||
onMount(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)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
await CheckIfMyAnimeListLoggedIn().then(loggedIn => {
|
||||
if (loggedIn) {
|
||||
GetMyAnimeListLoggedInUser().then(user => {
|
||||
malUser.set(user)
|
||||
if (isMalPrimary) {
|
||||
GetMyAnimeList(1000).then(watchList => {
|
||||
malWatchList.set(watchList)
|
||||
malLoggedIn.set(loggedIn)
|
||||
})
|
||||
} else {
|
||||
malLoggedIn.set(loggedIn)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
await CheckIfSimklLoggedIn().then(loggedIn => {
|
||||
if (loggedIn) {
|
||||
GetSimklLoggedInUser().then(user => {
|
||||
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
await CheckIfAniListLoggedInAndLoadWatchList()
|
||||
await CheckIfMALLoggedInAndSetUser()
|
||||
await CheckIfSimklLoggedInAndSetUser()
|
||||
})
|
||||
</script>
|
||||
|
||||
|
Reference in New Issue
Block a user