Fixed Simkl Bugs
This commit is contained in:
@ -4,28 +4,30 @@
|
||||
anilistModal,
|
||||
aniListPrimary,
|
||||
aniListUser,
|
||||
malUser,
|
||||
malLoggedIn,
|
||||
aniListWatchlist,
|
||||
animePerPage,
|
||||
GetAniListSingleItemAndOpenModal,
|
||||
malLoggedIn,
|
||||
malPrimary,
|
||||
malUser,
|
||||
malWatchList,
|
||||
simklLoggedIn,
|
||||
simklUser,
|
||||
simklWatchList,
|
||||
title,
|
||||
watchListPage,
|
||||
animePerPage,
|
||||
malWatchList,
|
||||
malPrimary
|
||||
simklPrimary,
|
||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||
import {
|
||||
CheckIfAniListLoggedIn,
|
||||
CheckIfSimklLoggedIn,
|
||||
CheckIfMyAnimeListLoggedIn,
|
||||
CheckIfSimklLoggedIn,
|
||||
GetAniListLoggedInUser,
|
||||
GetAniListUserWatchingList,
|
||||
GetMyAnimeList,
|
||||
GetMyAnimeListLoggedInUser,
|
||||
GetSimklLoggedInUser,
|
||||
SimklGetUserWatchlist,
|
||||
GetMyAnimeListLoggedInUser, GetMyAnimeList,
|
||||
} from "../wailsjs/go/main/App";
|
||||
import {MediaListSort} from "./anilist/types/AniListTypes";
|
||||
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
|
||||
@ -40,12 +42,14 @@
|
||||
let isAniListLoggedIn: boolean
|
||||
let isAniListPrimary: boolean
|
||||
let isMalPrimary: boolean
|
||||
let isSimklPrimary: boolean
|
||||
let aniListWatchListLoaded: AniListCurrentUserWatchList
|
||||
|
||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||
aniListPrimary.subscribe((value) => isAniListPrimary = value)
|
||||
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
||||
malPrimary.subscribe((value) => isMalPrimary = value)
|
||||
simklPrimary.subscribe(value => isSimklPrimary = value)
|
||||
|
||||
|
||||
let page: number
|
||||
@ -75,7 +79,7 @@
|
||||
if (loggedIn) {
|
||||
GetMyAnimeListLoggedInUser().then(user => {
|
||||
malUser.set(user)
|
||||
if (isMalPrimary){
|
||||
if (isMalPrimary) {
|
||||
GetMyAnimeList(1000).then(watchList => {
|
||||
malWatchList.set(watchList)
|
||||
malLoggedIn.set(loggedIn)
|
||||
@ -90,11 +94,19 @@
|
||||
await CheckIfSimklLoggedIn().then(loggedIn => {
|
||||
if (loggedIn) {
|
||||
GetSimklLoggedInUser().then(user => {
|
||||
simklUser.set(user)
|
||||
SimklGetUserWatchlist().then(result => {
|
||||
simklWatchList.set(result)
|
||||
simklLoggedIn.set(loggedIn)
|
||||
})
|
||||
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)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -107,15 +119,19 @@
|
||||
{#if isAniListLoggedIn}
|
||||
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8 relative items-center">
|
||||
<div id="spinner" role="status" class="fixed hidden -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
|
||||
<svg aria-hidden="true" class="inline w-16 h-16 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600" viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z" fill="currentColor"/>
|
||||
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z" fill="currentFill"/>
|
||||
<svg aria-hidden="true"
|
||||
class="inline w-16 h-16 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
||||
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||
fill="currentColor"/>
|
||||
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||
fill="currentFill"/>
|
||||
</svg>
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
<h1 class="text-left text-xl font-bold mb-4">Your AniList WatchList</h1>
|
||||
|
||||
<Pagination />
|
||||
<Pagination/>
|
||||
|
||||
<div class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8">
|
||||
{#each aniListWatchListLoaded.data.Page.mediaList as media}
|
||||
@ -153,7 +169,7 @@
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<Pagination />
|
||||
<Pagination/>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
|
@ -5,7 +5,8 @@
|
||||
aniListLoggedIn,
|
||||
simklLoggedIn,
|
||||
malLoggedIn,
|
||||
malAnime
|
||||
malAnime,
|
||||
simklAnime,
|
||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||
import {aniListAnime} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||
import {Button} from "flowbite-svelte";
|
||||
@ -14,8 +15,7 @@
|
||||
import moment from 'moment'
|
||||
import { Table, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell } from 'flowbite-svelte';
|
||||
import { writable } from 'svelte/store';
|
||||
import type {SimklAnime} from "./simkl/types/simklTypes";
|
||||
import { get } from 'svelte/store';
|
||||
import type {SimklAnime, SimklWatchList} from "./simkl/types/simklTypes";
|
||||
import {
|
||||
AniListUpdateEntry, MyAnimeListUpdate,
|
||||
SimklSyncEpisodes,
|
||||
@ -25,13 +25,12 @@
|
||||
import type {MALAnime, MALUploadStatus, MyListStatus} from "./mal/types/MALTypes";
|
||||
import type {AniListUpdateVariables} from "./anilist/types/AniListTypes";
|
||||
|
||||
const simklWatch = get(simklWatchList);
|
||||
let simklWatch: SimklWatchList
|
||||
let isAniListLoggedIn: boolean
|
||||
let isMalLoggedIn: boolean
|
||||
let isSimklLoggedIn: boolean
|
||||
let simklAnimeIndex: number
|
||||
let currentMalAnime: MALAnime
|
||||
let simklAnime: SimklAnime | undefined = undefined
|
||||
let currentSimklAnime: SimklAnime
|
||||
let submitting = writable(false)
|
||||
let isSubmitting: boolean
|
||||
|
||||
@ -40,13 +39,8 @@
|
||||
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
||||
malAnime.subscribe((value) => currentMalAnime = value)
|
||||
submitting.subscribe((value) => isSubmitting = value)
|
||||
|
||||
for (let i = 0; i < simklWatch.anime.length; i++) {
|
||||
if (Number(simklWatch.anime[i].show.ids.mal) === aniListAnime.data.MediaList.media.idMal) {
|
||||
simklAnimeIndex = i
|
||||
simklAnime = simklWatch.anime[i]
|
||||
}
|
||||
}
|
||||
simklWatchList.subscribe((value) => simklWatch = value)
|
||||
simklAnime.subscribe((value) => currentSimklAnime = value)
|
||||
|
||||
type statusOption = {
|
||||
id: number,
|
||||
@ -108,15 +102,15 @@
|
||||
})
|
||||
}
|
||||
|
||||
if(isSimklLoggedIn && simklAnime !== undefined) {
|
||||
if(isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0) {
|
||||
items.push({
|
||||
id: simklAnime.show.ids.simkl,
|
||||
id: currentSimklAnime.show.ids.simkl,
|
||||
service: "Simkl",
|
||||
progress: simklAnime.watched_episodes_count,
|
||||
status: simklAnime.status,
|
||||
progress: currentSimklAnime.watched_episodes_count,
|
||||
status: currentSimklAnime.status,
|
||||
startedAt: "",
|
||||
completedAt: "",
|
||||
score: simklAnime.user_rating,
|
||||
score: currentSimklAnime.user_rating,
|
||||
repeat: 0,
|
||||
notes: ""
|
||||
})
|
||||
@ -299,24 +293,24 @@
|
||||
}
|
||||
|
||||
if (simklLoggedIn) {
|
||||
if (simklAnime.watched_episodes_count !== values.progress) {
|
||||
await SimklSyncEpisodes(simklAnime, values.progress).then(() => {
|
||||
simklAnime.watched_episodes_count = values.progress
|
||||
simklWatch.anime[simklAnimeIndex].watched_episodes_count = values.progress
|
||||
if (currentSimklAnime.watched_episodes_count !== values.progress) {
|
||||
await SimklSyncEpisodes(currentSimklAnime, values.progress).then(() => {
|
||||
currentSimklAnime.watched_episodes_count = values.progress
|
||||
simklWatch.anime[simklWatch.currentIndex].watched_episodes_count = values.progress
|
||||
})
|
||||
}
|
||||
|
||||
if (simklAnime.user_rating !== values.score) {
|
||||
await SimklSyncRating(simklAnime, values.score).then(() => {
|
||||
simklAnime.user_rating = values.score
|
||||
simklWatch.anime[simklAnimeIndex].user_rating = values.score
|
||||
if (currentSimklAnime.user_rating !== values.score) {
|
||||
await SimklSyncRating(currentSimklAnime, values.score).then(() => {
|
||||
currentSimklAnime.user_rating = values.score
|
||||
simklWatch.anime[simklWatch.currentIndex].user_rating = values.score
|
||||
})
|
||||
}
|
||||
|
||||
if (simklAnime.status !== values.status.simkl) {
|
||||
await SimklSyncStatus(simklAnime, values.status.simkl).then(() => {
|
||||
simklAnime.status = values.status.simkl
|
||||
simklWatch.anime[simklAnimeIndex].status = values.status.simkl
|
||||
if (currentSimklAnime.status !== values.status.simkl) {
|
||||
await SimklSyncStatus(currentSimklAnime, values.status.simkl).then(() => {
|
||||
currentSimklAnime.status = values.status.simkl
|
||||
simklWatch.anime[simklWatch.currentIndex].status = values.status.simkl
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,23 @@
|
||||
<script lang="ts" context="module">
|
||||
import {
|
||||
GetAniListItem,
|
||||
GetAniListLoggedInUser, GetAniListUserWatchingList, GetMyAnimeListAnime, GetMyAnimeListLoggedInUser,
|
||||
GetSimklLoggedInUser, LogoutAniList, LogoutMyAnimeList, LogoutSimkl
|
||||
GetAniListLoggedInUser,
|
||||
GetAniListUserWatchingList,
|
||||
GetMyAnimeListAnime,
|
||||
GetMyAnimeListLoggedInUser,
|
||||
GetSimklLoggedInUser,
|
||||
LogoutAniList,
|
||||
LogoutMyAnimeList,
|
||||
LogoutSimkl,
|
||||
SimklGetUserWatchlist,
|
||||
SimklSearch
|
||||
} from "../wailsjs/go/main/App";
|
||||
import type {
|
||||
AniListCurrentUserWatchList,
|
||||
AniListGetSingleAnime
|
||||
} from "./anilist/types/AniListCurrentUserWatchListType.js";
|
||||
import {writable} from 'svelte/store'
|
||||
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
||||
import type {SimklAnime, SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
||||
import {type AniListUser, MediaListSort} from "./anilist/types/AniListTypes";
|
||||
import type {MALAnime, MALWatchlist, MyAnimeListUser} from "./mal/types/MALTypes";
|
||||
|
||||
@ -21,6 +29,7 @@
|
||||
export let malLoggedIn = writable(false)
|
||||
export let simklWatchList = writable({} as SimklWatchList)
|
||||
export let aniListPrimary = writable(true)
|
||||
export let simklPrimary = writable(false)
|
||||
export let malPrimary = writable(false)
|
||||
export let simklUser = writable({} as SimklUser)
|
||||
export let aniListUser = writable({} as AniListUser)
|
||||
@ -28,6 +37,7 @@
|
||||
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
|
||||
export let malWatchList = writable({} as MALWatchlist)
|
||||
export let malAnime = writable({} as MALAnime)
|
||||
export let simklAnime = writable({} as SimklAnime)
|
||||
|
||||
export let watchListPage = writable(1)
|
||||
export let animePerPage = writable(20)
|
||||
@ -36,14 +46,20 @@
|
||||
let page: number
|
||||
let perPage: number
|
||||
let aniWatchlist: AniListCurrentUserWatchList
|
||||
let simklWatch: SimklWatchList
|
||||
let currentSimklAnime: SimklAnime
|
||||
|
||||
let isMalLoggedIn: boolean
|
||||
let isSimklLoggedIn: boolean
|
||||
|
||||
aniListPrimary.subscribe(value => isAniListPrimary = value)
|
||||
watchListPage.subscribe(value => page = value)
|
||||
animePerPage.subscribe(value => perPage = value)
|
||||
aniListWatchlist.subscribe(value => aniWatchlist = value)
|
||||
malLoggedIn.subscribe(value => isMalLoggedIn = value)
|
||||
simklLoggedIn.subscribe(value => isSimklLoggedIn = value)
|
||||
simklWatchList.subscribe(value => simklWatch = value)
|
||||
simklAnime.subscribe(value => currentSimklAnime = value)
|
||||
|
||||
|
||||
export async function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): Promise<""> {
|
||||
@ -52,24 +68,32 @@
|
||||
title.set(aniListAnime.data.MediaList.media.title.english === "" ?
|
||||
aniListAnime.data.MediaList.media.title.romaji :
|
||||
aniListAnime.data.MediaList.media.title.english)
|
||||
if(isMalLoggedIn) {
|
||||
GetMyAnimeListAnime(aniListAnime.data.MediaList.media.idMal).then(malResult => {
|
||||
malAnime.set(malResult)
|
||||
anilistModal.set(true)
|
||||
return ""
|
||||
})
|
||||
} else {
|
||||
anilistModal.set(true)
|
||||
return ""
|
||||
}
|
||||
})
|
||||
if (isMalLoggedIn) {
|
||||
await GetMyAnimeListAnime(aniListAnime.data.MediaList.media.idMal).then(malResult => {
|
||||
malAnime.set(malResult)
|
||||
})
|
||||
}
|
||||
if (isSimklLoggedIn) {
|
||||
await SimklSearch(aniListAnime.data.MediaList.media.id).then((value: SimklAnime) => {
|
||||
simklAnime.set(value)
|
||||
})
|
||||
}
|
||||
anilistModal.set(true)
|
||||
return ""
|
||||
}
|
||||
|
||||
export function loginToSimkl(): void {
|
||||
GetSimklLoggedInUser().then(result => {
|
||||
simklUser.set(result)
|
||||
simklLoggedIn.set(true)
|
||||
GetSimklLoggedInUser().then(user => {
|
||||
if (Object.keys(user).length === 0) {
|
||||
simklLoggedIn.set(false)
|
||||
} else {
|
||||
simklUser.set(user)
|
||||
SimklGetUserWatchlist().then(result => {
|
||||
simklWatchList.set(result)
|
||||
simklLoggedIn.set(true)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
function runAniListSearch(): void {
|
||||
AniListSearch(aniSearch).then(result => {
|
||||
console.log(result.data.Page.media[5])
|
||||
aniListSearch = result
|
||||
aniListSearchActive = true
|
||||
})
|
||||
|
@ -20,6 +20,7 @@ export type SimklUser = {
|
||||
|
||||
export type SimklWatchList = {
|
||||
anime: [SimklAnime]
|
||||
currentIndex: number
|
||||
}
|
||||
|
||||
export type SimklAnime = {
|
||||
@ -58,4 +59,18 @@ export type SimklAnime = {
|
||||
}
|
||||
},
|
||||
anime_type: string
|
||||
}
|
||||
}
|
||||
|
||||
export type SimklSearchType = [{
|
||||
type: string;
|
||||
title: string;
|
||||
poster: string;
|
||||
year: number;
|
||||
status: string;
|
||||
ids: {
|
||||
simkl: number;
|
||||
slug: string;
|
||||
};
|
||||
totalEpisodes: number;
|
||||
animeType: string;
|
||||
}]
|
Reference in New Issue
Block a user