fixed app to work with global variables
This commit is contained in:
parent
49e461d0ff
commit
aaf0f421f2
@ -1,5 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {anilistModal, GetAniListSingleItemAndOpenModal, title} from "./GetAniListSingleItemAndOpenModal.svelte";
|
import {
|
||||||
|
anilistModal,
|
||||||
|
GetAniListSingleItemAndOpenModal,
|
||||||
|
title,
|
||||||
|
simklWatchList,
|
||||||
|
aniListLoggedIn,
|
||||||
|
simklLoggedIn
|
||||||
|
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import {
|
import {
|
||||||
CheckIfAniListLoggedIn,
|
CheckIfAniListLoggedIn,
|
||||||
CheckIfSimklLoggedIn,
|
CheckIfSimklLoggedIn,
|
||||||
@ -15,16 +22,18 @@
|
|||||||
import {default as Modal} from "./modal/Modal.svelte"
|
import {default as Modal} from "./modal/Modal.svelte"
|
||||||
import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
|
import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
|
||||||
import {onMount} from "svelte";
|
import {onMount} from "svelte";
|
||||||
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
import type {SimklUser} from "./simkl/types/simklTypes";
|
||||||
import {writable} from "svelte/store";
|
|
||||||
|
|
||||||
let aniListLoggedIn = false
|
|
||||||
let aniListPrimary = true
|
let aniListPrimary = true
|
||||||
let simklUser: SimklUser
|
let simklUser: SimklUser
|
||||||
let simklLoggedIn = false
|
|
||||||
let aniListUser: AniListUser
|
let aniListUser: AniListUser
|
||||||
let aniListWatchlist: AniListCurrentUserWatchList
|
let aniListWatchlist: AniListCurrentUserWatchList
|
||||||
export let simklWatchList = writable({} as SimklWatchList)
|
let isAniListLoggedIn: boolean
|
||||||
|
let isSimklLoggedIn: boolean
|
||||||
|
|
||||||
|
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||||
|
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
||||||
|
|
||||||
let page = 1
|
let page = 1
|
||||||
let perPage = 20
|
let perPage = 20
|
||||||
const size = "xl"
|
const size = "xl"
|
||||||
@ -37,10 +46,10 @@
|
|||||||
if (aniListPrimary) {
|
if (aniListPrimary) {
|
||||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
aniListWatchlist = result
|
aniListWatchlist = result
|
||||||
aniListLoggedIn = true
|
aniListLoggedIn.set(true)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
aniListLoggedIn = result
|
aniListLoggedIn.set(result)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -52,7 +61,7 @@
|
|||||||
simklUser = result
|
simklUser = result
|
||||||
SimklGetUserWatchlist().then(result => {
|
SimklGetUserWatchlist().then(result => {
|
||||||
simklWatchList.set(result)
|
simklWatchList.set(result)
|
||||||
simklLoggedIn = result
|
simklLoggedIn.set(result)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -62,14 +71,14 @@
|
|||||||
function loginToSimkl(): void {
|
function loginToSimkl(): void {
|
||||||
GetSimklLoggedInUser().then(result => {
|
GetSimklLoggedInUser().then(result => {
|
||||||
simklUser = result
|
simklUser = result
|
||||||
simklLoggedIn = true
|
simklLoggedIn.set(true)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginToAniList(): void {
|
function loginToAniList(): void {
|
||||||
GetAniListLoggedInUser().then(result => {
|
GetAniListLoggedInUser().then(result => {
|
||||||
aniListUser = result
|
aniListUser = result
|
||||||
aniListLoggedIn = true
|
aniListLoggedIn.set(true)
|
||||||
if (aniListPrimary) {
|
if (aniListPrimary) {
|
||||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then(result => aniListWatchlist = result)
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then(result => aniListWatchlist = result)
|
||||||
}
|
}
|
||||||
@ -79,7 +88,7 @@
|
|||||||
// function anilistGetUserWatchlist(): void {
|
// function anilistGetUserWatchlist(): void {
|
||||||
// GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
// GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
// aniListWatchlist = result
|
// aniListWatchlist = result
|
||||||
// aniListLoggedIn = true
|
// aniListLoggedIn.set(true)
|
||||||
// })
|
// })
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
@ -101,19 +110,19 @@
|
|||||||
<Header/>
|
<Header/>
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
{#if aniListLoggedIn}
|
{#if isAniListLoggedIn}
|
||||||
<div>You are logged into AniList, {aniListWatchlist.data.Page.mediaList[0].user.name}!</div>
|
<div>You are logged into AniList, {aniListUser.data.Viewer.name}!</div>
|
||||||
{:else}
|
{:else}
|
||||||
<button class="btn" on:click={loginToAniList}>Login to AniList</button>
|
<button class="btn" on:click={loginToAniList}>Login to AniList</button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if simklLoggedIn}
|
{#if isSimklLoggedIn}
|
||||||
<div>You are logged into Simkl, {simklUser.user.name}</div>
|
<div>You are logged into Simkl, {simklUser.user.name}</div>
|
||||||
{:else}
|
{:else}
|
||||||
<Button class="btn" on:click={loginToSimkl}>Login to Simkl</Button>
|
<Button class="btn" on:click={loginToSimkl}>Login to Simkl</Button>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if aniListLoggedIn}
|
{#if isAniListLoggedIn}
|
||||||
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8">
|
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8">
|
||||||
<h1 class="text-left text-xl font-bold mb-4">Your Watching List</h1>
|
<h1 class="text-left text-xl font-bold mb-4">Your Watching List</h1>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user