fixed frontend login updating
This commit is contained in:
parent
03413cd11a
commit
a0e193e343
@ -12,6 +12,8 @@
|
|||||||
simklUser,
|
simklUser,
|
||||||
simklWatchList,
|
simklWatchList,
|
||||||
title,
|
title,
|
||||||
|
watchListPage,
|
||||||
|
animePerPage,
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import {
|
import {
|
||||||
CheckIfAniListLoggedIn,
|
CheckIfAniListLoggedIn,
|
||||||
@ -41,8 +43,10 @@
|
|||||||
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
||||||
|
|
||||||
|
|
||||||
let page = 1
|
let page: number
|
||||||
let perPage = 20
|
let perPage: number
|
||||||
|
watchListPage.subscribe(value => page = value)
|
||||||
|
animePerPage.subscribe(value => perPage = value)
|
||||||
const size = "xl"
|
const size = "xl"
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
@ -84,9 +88,9 @@
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function ChangeWathcListPage(newPage: number) {
|
function ChangeWatchListPage(newPage: number) {
|
||||||
GetAniListUserWatchingList(newPage, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
GetAniListUserWatchingList(newPage, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
page = newPage
|
watchListPage.set(newPage)
|
||||||
aniListWatchlist.set(result)
|
aniListWatchlist.set(result)
|
||||||
aniListLoggedIn.set(true)
|
aniListLoggedIn.set(true)
|
||||||
})
|
})
|
||||||
@ -111,19 +115,19 @@
|
|||||||
</li>
|
</li>
|
||||||
{:else}
|
{:else}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(page-1)}
|
<button on:click={() => ChangeWatchListPage(page-1)}
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
||||||
{#if i+1 === page}
|
{#if i+1 === page}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(i+1)}
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
||||||
</li>
|
</li>
|
||||||
{:else}
|
{:else}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(i+1)}
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
@ -136,7 +140,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{:else}
|
{:else}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(page+1)}
|
<button on:click={() => ChangeWatchListPage(page+1)}
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
@ -188,19 +192,19 @@
|
|||||||
</li>
|
</li>
|
||||||
{:else}
|
{:else}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(page-1)}
|
<button on:click={() => ChangeWatchListPage(page-1)}
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
||||||
{#if i+1 === page}
|
{#if i+1 === page}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(i+1)}
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
||||||
</li>
|
</li>
|
||||||
{:else}
|
{:else}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(i+1)}
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
@ -213,7 +217,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{:else}
|
{:else}
|
||||||
<li>
|
<li>
|
||||||
<button on:click={() => ChangeWathcListPage(page+1)}
|
<button on:click={() => ChangeWatchListPage(page+1)}
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script lang="ts" context="module">
|
<script lang="ts" context="module">
|
||||||
import {
|
import {
|
||||||
GetAniListItem,
|
GetAniListItem,
|
||||||
GetAniListLoggedInUser, GetMyAnimeListLoggedInUser,
|
GetAniListLoggedInUser, GetAniListUserWatchingList, GetMyAnimeListLoggedInUser,
|
||||||
GetSimklLoggedInUser
|
GetSimklLoggedInUser
|
||||||
} from "../wailsjs/go/main/App";
|
} from "../wailsjs/go/main/App";
|
||||||
import type {
|
import type {
|
||||||
@ -10,7 +10,7 @@
|
|||||||
} from "./anilist/types/AniListCurrentUserWatchListType.js";
|
} from "./anilist/types/AniListCurrentUserWatchListType.js";
|
||||||
import {writable} from 'svelte/store'
|
import {writable} from 'svelte/store'
|
||||||
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
||||||
import {type AniListUser} from "./anilist/types/AniListTypes";
|
import {type AniListUser, MediaListSort} from "./anilist/types/AniListTypes";
|
||||||
import type {MyAnimeListUser} from "./mal/types/MALTypes";
|
import type {MyAnimeListUser} from "./mal/types/MALTypes";
|
||||||
|
|
||||||
export let aniListAnime: AniListGetSingleAnime
|
export let aniListAnime: AniListGetSingleAnime
|
||||||
@ -26,6 +26,16 @@
|
|||||||
export let malUser = writable({} as MyAnimeListUser)
|
export let malUser = writable({} as MyAnimeListUser)
|
||||||
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
|
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
|
||||||
|
|
||||||
|
export let watchListPage = writable(1)
|
||||||
|
export let animePerPage = writable(20)
|
||||||
|
|
||||||
|
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 function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
|
export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
|
||||||
GetAniListItem(aniId, login).then(result => {
|
GetAniListItem(aniId, login).then(result => {
|
||||||
aniListAnime = result
|
aniListAnime = result
|
||||||
@ -46,7 +56,14 @@
|
|||||||
export function loginToAniList(): void {
|
export function loginToAniList(): void {
|
||||||
GetAniListLoggedInUser().then(result => {
|
GetAniListLoggedInUser().then(result => {
|
||||||
aniListUser.set(result)
|
aniListUser.set(result)
|
||||||
aniListLoggedIn.set(true)
|
if (isAniListPrimary) {
|
||||||
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
|
aniListWatchlist.set(result)
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user