made a bunch of frontend variables global

This commit is contained in:
2024-08-11 20:27:58 -04:00
parent d644758253
commit 8daf3af5f9
3 changed files with 75 additions and 54 deletions

View File

@@ -1,8 +1,16 @@
<script lang="ts" context="module">
import {GetAniListItem} from "../wailsjs/go/main/App";
import type {AniListGetSingleAnime} from "./anilist/types/AniListCurrentUserWatchListType.js";
import {
GetAniListItem,
GetAniListLoggedInUser,
GetSimklLoggedInUser
} from "../wailsjs/go/main/App";
import type {
AniListCurrentUserWatchList,
AniListGetSingleAnime
} from "./anilist/types/AniListCurrentUserWatchListType.js";
import {writable} from 'svelte/store'
import type {SimklWatchList} from "./simkl/types/simklTypes";
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
import {type AniListUser} from "./anilist/types/AniListTypes";
export let aniListAnime: AniListGetSingleAnime
export let title = writable("")
@@ -10,6 +18,10 @@
export let aniListLoggedIn = writable(false)
export let simklLoggedIn = writable(false)
export let simklWatchList = writable({} as SimklWatchList)
export let aniListPrimary = writable(true)
export let simklUser = writable({} as SimklUser)
export let aniListUser = writable({} as AniListUser)
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
GetAniListItem(aniId, login).then(result => {
@@ -20,4 +32,18 @@
anilistModal.set(true)
})
}
export function loginToSimkl(): void {
GetSimklLoggedInUser().then(result => {
simklUser = result
simklLoggedIn.set(true)
})
}
export function loginToAniList(): void {
GetAniListLoggedInUser().then(result => {
aniListUser = result
aniListLoggedIn.set(true)
})
}
</script>