25 lines
1004 B
Svelte
25 lines
1004 B
Svelte
<script lang="ts" context="module">
|
|
import {CheckIfMyAnimeListLoggedIn, GetMyAnimeList, GetMyAnimeListLoggedInUser} from "../../wailsjs/go/main/App";
|
|
import {malUser, malPrimary, malWatchList, malLoggedIn} from "./GlobalVariablesAndHelperFunctions.svelte"
|
|
|
|
let isMalPrimary: boolean
|
|
malPrimary.subscribe(value => isMalPrimary = value)
|
|
|
|
export const CheckIfMALLoggedInAndSetUser = async () => {
|
|
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)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
}
|
|
</script> |