improved loading for change individual anime from search
This commit is contained in:
parent
45b11fa8f4
commit
60a38ff569
@ -1,6 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
aniListLoggedIn,
|
|
||||||
aniListAnime,
|
aniListAnime,
|
||||||
GetAniListSingleItem,
|
GetAniListSingleItem,
|
||||||
} from "./helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
} from "./helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
@ -13,6 +12,8 @@
|
|||||||
import {CheckIfAniListLoggedInAndLoadWatchList} from "./helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
import {CheckIfAniListLoggedInAndLoadWatchList} from "./helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||||
import { CheckIfMALLoggedInAndSetUser } from "./helperModules/CheckIfMyAnimeListLoggedIn.svelte";
|
import { CheckIfMALLoggedInAndSetUser } from "./helperModules/CheckIfMyAnimeListLoggedIn.svelte";
|
||||||
import {CheckIfSimklLoggedInAndSetUser} from "./helperModules/CheckIsSimklLoggedIn.svelte"
|
import {CheckIfSimklLoggedInAndSetUser} from "./helperModules/CheckIsSimklLoggedIn.svelte"
|
||||||
|
import {CheckIfAniListLoggedIn} from "../wailsjs/go/main/App";
|
||||||
|
import {AniListGetSingleAnimeDefaultData} from "./helperDefaults/AniListGetSingleAnime";
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await CheckIfAniListLoggedInAndLoadWatchList()
|
await CheckIfAniListLoggedInAndLoadWatchList()
|
||||||
@ -25,10 +26,15 @@
|
|||||||
<Router routes={{
|
<Router routes={{
|
||||||
'/': Home,
|
'/': Home,
|
||||||
'/anime/:id': wrap({
|
'/anime/:id': wrap({
|
||||||
asyncComponent: () => import('./routes/Anime.svelte'),
|
asyncComponent: () => import('./routes/AnimeRoutePage.svelte'),
|
||||||
conditions: [
|
conditions: [
|
||||||
() => $aniListLoggedIn,
|
async () => await CheckIfAniListLoggedIn(),
|
||||||
async (detail) => {
|
async (detail) => {
|
||||||
|
console.log("reached condition")
|
||||||
|
aniListAnime.update(value => {
|
||||||
|
value = AniListGetSingleAnimeDefaultData
|
||||||
|
return value
|
||||||
|
})
|
||||||
await GetAniListSingleItem(Number(detail.params.id), true)
|
await GetAniListSingleItem(Number(detail.params.id), true)
|
||||||
return Object.keys($aniListAnime).length!==0
|
return Object.keys($aniListAnime).length!==0
|
||||||
},
|
},
|
||||||
|
@ -7,12 +7,12 @@
|
|||||||
simklAnime,
|
simklAnime,
|
||||||
simklLoggedIn,
|
simklLoggedIn,
|
||||||
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
import {pop} from "svelte-spa-router";
|
import {push} from "svelte-spa-router";
|
||||||
import {Button} from "flowbite-svelte";
|
import {Button} from "flowbite-svelte";
|
||||||
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
|
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
|
||||||
import Rating from "../helperComponents/Rating.svelte";
|
import Rating from "./Rating.svelte";
|
||||||
import convertAniListDateToString from "../helperFunctions/convertAniListDateToString";
|
import convertAniListDateToString from "../helperFunctions/convertAniListDateToString";
|
||||||
import AnimeTable from "../helperComponents/AnimeTable.svelte";
|
import AnimeTable from "./AnimeTable.svelte";
|
||||||
import type {MALAnime, MalListStatus, MALUploadStatus} from "../mal/types/MALTypes";
|
import type {MALAnime, MalListStatus, MALUploadStatus} from "../mal/types/MALTypes";
|
||||||
import type {SimklAnime} from "../simkl/types/simklTypes";
|
import type {SimklAnime} from "../simkl/types/simklTypes";
|
||||||
import {writable} from "svelte/store";
|
import {writable} from "svelte/store";
|
||||||
@ -64,6 +64,7 @@
|
|||||||
|
|
||||||
if (isAniListLoggedIn) AddAnimeServiceToTable({
|
if (isAniListLoggedIn) AddAnimeServiceToTable({
|
||||||
id: currentAniListAnime.data.MediaList.id,
|
id: currentAniListAnime.data.MediaList.id,
|
||||||
|
title,
|
||||||
service: "AniList",
|
service: "AniList",
|
||||||
progress: currentAniListAnime.data.MediaList.progress,
|
progress: currentAniListAnime.data.MediaList.progress,
|
||||||
status: currentAniListAnime.data.MediaList.status,
|
status: currentAniListAnime.data.MediaList.status,
|
||||||
@ -77,6 +78,7 @@
|
|||||||
|
|
||||||
if (isMalLoggedIn) AddAnimeServiceToTable({
|
if (isMalLoggedIn) AddAnimeServiceToTable({
|
||||||
id: currentMalAnime.id,
|
id: currentMalAnime.id,
|
||||||
|
title: currentMalAnime.title,
|
||||||
service: "MyAnimeList",
|
service: "MyAnimeList",
|
||||||
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
||||||
status: currentMalAnime.my_list_status.status,
|
status: currentMalAnime.my_list_status.status,
|
||||||
@ -89,6 +91,7 @@
|
|||||||
|
|
||||||
if (isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0) AddAnimeServiceToTable({
|
if (isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0) AddAnimeServiceToTable({
|
||||||
id: currentSimklAnime.show.ids.simkl,
|
id: currentSimklAnime.show.ids.simkl,
|
||||||
|
title: currentSimklAnime.show.title,
|
||||||
service: "Simkl",
|
service: "Simkl",
|
||||||
progress: currentSimklAnime.watched_episodes_count,
|
progress: currentSimklAnime.watched_episodes_count,
|
||||||
status: currentSimklAnime.status,
|
status: currentSimklAnime.status,
|
||||||
@ -166,6 +169,7 @@
|
|||||||
})
|
})
|
||||||
AddAnimeServiceToTable({
|
AddAnimeServiceToTable({
|
||||||
id: currentAniListAnime.data.MediaList.id,
|
id: currentAniListAnime.data.MediaList.id,
|
||||||
|
title,
|
||||||
service: "AniList",
|
service: "AniList",
|
||||||
progress: currentAniListAnime.data.MediaList.progress,
|
progress: currentAniListAnime.data.MediaList.progress,
|
||||||
status: currentAniListAnime.data.MediaList.status,
|
status: currentAniListAnime.data.MediaList.status,
|
||||||
@ -200,6 +204,7 @@
|
|||||||
})
|
})
|
||||||
AddAnimeServiceToTable({
|
AddAnimeServiceToTable({
|
||||||
id: currentMalAnime.id,
|
id: currentMalAnime.id,
|
||||||
|
title: currentMalAnime.title,
|
||||||
service: "MyAnimeList",
|
service: "MyAnimeList",
|
||||||
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
||||||
status: currentMalAnime.my_list_status.status,
|
status: currentMalAnime.my_list_status.status,
|
||||||
@ -217,6 +222,7 @@
|
|||||||
await SimklSyncEpisodes(currentSimklAnime, submitData.episodes).then((value: SimklAnime) => {
|
await SimklSyncEpisodes(currentSimklAnime, submitData.episodes).then((value: SimklAnime) => {
|
||||||
AddAnimeServiceToTable({
|
AddAnimeServiceToTable({
|
||||||
id: value.show.ids.simkl,
|
id: value.show.ids.simkl,
|
||||||
|
title: value.show.title,
|
||||||
service: "Simkl",
|
service: "Simkl",
|
||||||
progress: value.watched_episodes_count,
|
progress: value.watched_episodes_count,
|
||||||
status: value.status,
|
status: value.status,
|
||||||
@ -237,6 +243,7 @@
|
|||||||
await SimklSyncRating(currentSimklAnime, submitData.rating).then(value => {
|
await SimklSyncRating(currentSimklAnime, submitData.rating).then(value => {
|
||||||
AddAnimeServiceToTable({
|
AddAnimeServiceToTable({
|
||||||
id: value.show.ids.simkl,
|
id: value.show.ids.simkl,
|
||||||
|
title: value.show.title,
|
||||||
service: "Simkl",
|
service: "Simkl",
|
||||||
progress: value.watched_episodes_count,
|
progress: value.watched_episodes_count,
|
||||||
status: value.status,
|
status: value.status,
|
||||||
@ -257,6 +264,7 @@
|
|||||||
await SimklSyncStatus(currentSimklAnime, submitData.status.simkl).then(value => {
|
await SimklSyncStatus(currentSimklAnime, submitData.status.simkl).then(value => {
|
||||||
AddAnimeServiceToTable({
|
AddAnimeServiceToTable({
|
||||||
id: value.show.ids.simkl,
|
id: value.show.ids.simkl,
|
||||||
|
title: value.show.title,
|
||||||
service: "Simkl",
|
service: "Simkl",
|
||||||
progress: value.watched_episodes_count,
|
progress: value.watched_episodes_count,
|
||||||
status: value.status,
|
status: value.status,
|
||||||
@ -280,6 +288,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<form on:submit|preventDefault={handleSubmit} class="container py-10">
|
<form on:submit|preventDefault={handleSubmit} class="container py-10">
|
||||||
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-10 grid-flow-col gap-4">
|
<div class="grid grid-cols-1 md:grid-cols-10 grid-flow-col gap-4">
|
||||||
<div class="md:col-span-2 space-y-3">
|
<div class="md:col-span-2 space-y-3">
|
||||||
<img class="rounded-lg" src={currentAniListAnime.data.MediaList.media.coverImage.large}
|
<img class="rounded-lg" src={currentAniListAnime.data.MediaList.media.coverImage.large}
|
||||||
@ -437,9 +446,9 @@
|
|||||||
dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700"
|
dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700"
|
||||||
on:click={async () => {
|
on:click={async () => {
|
||||||
await CheckIfAniListLoggedInAndLoadWatchList()
|
await CheckIfAniListLoggedInAndLoadWatchList()
|
||||||
return pop()
|
return push('/')
|
||||||
}}>
|
}}>
|
||||||
Back
|
Go Home
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -12,6 +12,10 @@
|
|||||||
header: "Service Id",
|
header: "Service Id",
|
||||||
accessor: 'id',
|
accessor: 'id',
|
||||||
}),
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Anime Title",
|
||||||
|
accessor: "title",
|
||||||
|
}),
|
||||||
table.column({
|
table.column({
|
||||||
header: 'Service',
|
header: 'Service',
|
||||||
accessor: 'service',
|
accessor: 'service',
|
||||||
|
@ -16,8 +16,7 @@
|
|||||||
import type {MyAnimeListUser} from "../mal/types/MALTypes";
|
import type {MyAnimeListUser} from "../mal/types/MALTypes";
|
||||||
import AvatarMenu from "./AvatarMenu.svelte";
|
import AvatarMenu from "./AvatarMenu.svelte";
|
||||||
import logo from "../assets/images/AniTrackLogo.svg"
|
import logo from "../assets/images/AniTrackLogo.svg"
|
||||||
import {location, pop} from "svelte-spa-router";
|
import {location} from "svelte-spa-router";
|
||||||
import {CheckIfAniListLoggedInAndLoadWatchList} from "../helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
|
||||||
|
|
||||||
let isAniListLoggedIn: boolean
|
let isAniListLoggedIn: boolean
|
||||||
let isSimklLoggedIn: boolean
|
let isSimklLoggedIn: boolean
|
||||||
@ -40,14 +39,7 @@
|
|||||||
<nav class="bg-white border-gray-200 dark:bg-gray-900">
|
<nav class="bg-white border-gray-200 dark:bg-gray-900">
|
||||||
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
||||||
<div class="flex items-center space-x-3 rtl:space-x-reverse">
|
<div class="flex items-center space-x-3 rtl:space-x-reverse">
|
||||||
{#if currentLocation === "/"}
|
|
||||||
<a href="/"><img src={logo} class="h-8" alt="AniTrack Logo"/></a>
|
<a href="/"><img src={logo} class="h-8" alt="AniTrack Logo"/></a>
|
||||||
{:else}
|
|
||||||
<button on:click={async () => {
|
|
||||||
await CheckIfAniListLoggedInAndLoadWatchList()
|
|
||||||
return pop()
|
|
||||||
}}><img src={logo} class="h-8" alt="AniTrack Logo"/></button>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center min-[950px]:order-2 space-x-3 min-[950px]:space-x-0 rtl:space-x-reverse">
|
<div class="flex items-center min-[950px]:order-2 space-x-3 min-[950px]:space-x-0 rtl:space-x-reverse">
|
||||||
<div class="min-[950px]:block min-[950px]:mr-4">
|
<div class="min-[950px]:block min-[950px]:mr-4">
|
||||||
|
65
frontend/src/helperDefaults/AniListGetSingleAnime.ts
Normal file
65
frontend/src/helperDefaults/AniListGetSingleAnime.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
|
||||||
|
|
||||||
|
export const AniListGetSingleAnimeDefaultData: AniListGetSingleAnime = {
|
||||||
|
data: {
|
||||||
|
MediaList: {
|
||||||
|
id: 0,
|
||||||
|
mediaId: 0,
|
||||||
|
userId: 0,
|
||||||
|
media: {
|
||||||
|
id: 0,
|
||||||
|
idMal: 0,
|
||||||
|
title: {
|
||||||
|
romaji: "",
|
||||||
|
english: "",
|
||||||
|
native: "",
|
||||||
|
},
|
||||||
|
description: "",
|
||||||
|
coverImage: {
|
||||||
|
large: "",
|
||||||
|
},
|
||||||
|
season: "",
|
||||||
|
seasonYear: 0,
|
||||||
|
status: "",
|
||||||
|
episodes: 0,
|
||||||
|
nextAiringEpisode: {
|
||||||
|
airingAt: 0,
|
||||||
|
timeUntilAiring: 0,
|
||||||
|
episode: 0,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
status: "",
|
||||||
|
startedAt: {
|
||||||
|
year: 0,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
},
|
||||||
|
completedAt: {
|
||||||
|
year: 0,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
},
|
||||||
|
notes: "",
|
||||||
|
progress: 0,
|
||||||
|
score: 0,
|
||||||
|
repeat: 0,
|
||||||
|
user: {
|
||||||
|
id: 0,
|
||||||
|
name: "",
|
||||||
|
avatar: {
|
||||||
|
large: "",
|
||||||
|
medium: "",
|
||||||
|
},
|
||||||
|
statistics: {
|
||||||
|
anime: {
|
||||||
|
count: 0,
|
||||||
|
statuses: [{
|
||||||
|
status: "",
|
||||||
|
count: 0,
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,21 +11,24 @@
|
|||||||
watchListPage.subscribe(value => page = value)
|
watchListPage.subscribe(value => page = value)
|
||||||
animePerPage.subscribe(value => perPage = value)
|
animePerPage.subscribe(value => perPage = value)
|
||||||
|
|
||||||
export const CheckIfAniListLoggedInAndLoadWatchList = async () => {
|
export const LoadAniListUser = async () => {
|
||||||
await CheckIfAniListLoggedIn().then(loggedIn => {
|
await GetAniListLoggedInUser().then(user => {
|
||||||
if (loggedIn) {
|
|
||||||
GetAniListLoggedInUser().then(user => {
|
|
||||||
aniListUser.set(user)
|
aniListUser.set(user)
|
||||||
if (isAniListPrimary) {
|
})
|
||||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
|
}
|
||||||
|
|
||||||
|
export const LoadAniListWatchList = async () => {
|
||||||
|
await GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
|
||||||
aniListWatchlist.set(watchList)
|
aniListWatchlist.set(watchList)
|
||||||
aniListLoggedIn.set(loggedIn)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
aniListLoggedIn.set(loggedIn)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
export const CheckIfAniListLoggedInAndLoadWatchList = async () => {
|
||||||
|
const loggedIn = await CheckIfAniListLoggedIn()
|
||||||
|
if (loggedIn) {
|
||||||
|
await LoadAniListUser()
|
||||||
|
if (isAniListPrimary) await LoadAniListWatchList()
|
||||||
|
}
|
||||||
|
aniListLoggedIn.set(loggedIn)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -21,8 +21,9 @@
|
|||||||
import {type AniListUser, MediaListSort} from "../anilist/types/AniListTypes";
|
import {type AniListUser, MediaListSort} from "../anilist/types/AniListTypes";
|
||||||
import type {MALAnime, MALWatchlist, MyAnimeListUser} from "../mal/types/MALTypes";
|
import type {MALAnime, MALWatchlist, MyAnimeListUser} from "../mal/types/MALTypes";
|
||||||
import type {TableItems} from "../helperTypes/TableTypes";
|
import type {TableItems} from "../helperTypes/TableTypes";
|
||||||
|
import {AniListGetSingleAnimeDefaultData} from "../helperDefaults/AniListGetSingleAnime";
|
||||||
|
|
||||||
export let aniListAnime = writable({} as AniListGetSingleAnime)
|
export let aniListAnime = writable(AniListGetSingleAnimeDefaultData)
|
||||||
export let title = writable("")
|
export let title = writable("")
|
||||||
export let aniListLoggedIn = writable(false)
|
export let aniListLoggedIn = writable(false)
|
||||||
export let simklLoggedIn = writable(false)
|
export let simklLoggedIn = writable(false)
|
||||||
|
@ -2,6 +2,7 @@ export type TableItems = TableItem[]
|
|||||||
|
|
||||||
export type TableItem = {
|
export type TableItem = {
|
||||||
id: number
|
id: number
|
||||||
|
title: string
|
||||||
service: string
|
service: string
|
||||||
progress: number
|
progress: number
|
||||||
status: string
|
status: string
|
||||||
|
9
frontend/src/routes/AnimeRoutePage.svelte
Normal file
9
frontend/src/routes/AnimeRoutePage.svelte
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Anime from "../helperComponents/Anime.svelte"
|
||||||
|
|
||||||
|
export let params: Record<string, string>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#key params.id}
|
||||||
|
<Anime />
|
||||||
|
{/key}
|
Loading…
Reference in New Issue
Block a user