diff --git a/package.json b/package.json index 6e07f8c..0c2055d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "6.1.5", + "version": "6.1.6", "license": "BUSL-1.1", "private": true, "packageManager": "pnpm@9.14.4", diff --git a/src/lib/components/ui/forums/Comments.svelte b/src/lib/components/ui/forums/Comments.svelte index 0250020..f52122e 100644 --- a/src/lib/components/ui/forums/Comments.svelte +++ b/src/lib/components/ui/forums/Comments.svelte @@ -19,8 +19,6 @@ const perPage = 15 $: count = $comments.data?.Page?.pageInfo?.total ?? 0 - - $: console.log($comments.fetching, $comments.error, $comments.data?.Page?.threadComments) diff --git a/src/lib/components/ui/player/player.svelte b/src/lib/components/ui/player/player.svelte index 753b6dd..9aae292 100644 --- a/src/lib/components/ui/player/player.svelte +++ b/src/lib/components/ui/player/player.svelte @@ -404,10 +404,10 @@ if (['ArrowLeft', 'ArrowRight'].includes(event.key)) event.stopPropagation() switch (event.key) { case 'ArrowLeft': - seek(-$settings.playerSeek) + seek(-Number($settings.playerSeek)) break case 'ArrowRight': - seek($settings.playerSeek) + seek(Number($settings.playerSeek)) break case 'Enter': playPause() @@ -509,7 +509,7 @@ }, ArrowLeft: { fn: () => { - seek(-$settings.playerSeek) + seek(-Number($settings.playerSeek)) }, id: 'fast_rewind', icon: Rewind, @@ -518,7 +518,7 @@ }, ArrowRight: { fn: () => { - seek($settings.playerSeek) + seek(Number($settings.playerSeek)) }, id: 'fast_forward', icon: FastForward, diff --git a/src/lib/components/ui/player/resolver.ts b/src/lib/components/ui/player/resolver.ts index 3714695..18d311b 100644 --- a/src/lib/components/ui/player/resolver.ts +++ b/src/lib/components/ui/player/resolver.ts @@ -36,7 +36,6 @@ export async function resolveFilesPoorly (promise: Promise<{media: Media, id: st const resolved = videoFiles.length === 1 ? [{ episode: list.episode, parseObject: (await anitomyscript([videoFiles[0]!.name]))[0]!, media: list.media, failed: false }] : await AnimeResolver.resolveFileAnime(videoFiles.map(file => file.name)) - console.log({ resolved, videoFiles }) const resolvedFiles: ResolvedFile[] = videoFiles.map(file => { return { ...file, @@ -315,7 +314,6 @@ const AnimeResolver = new class AnimeResolver { } return false }) as ResultOf | undefined - console.log(res) // this is hit-miss if (!res && !skip && type === 'SEQUEL') res = this.findEdge(media, type, formats = ['TV', 'TV_SHORT', 'OVA'], true) return res diff --git a/src/lib/components/ui/sidebar/SidebarButton.svelte b/src/lib/components/ui/sidebar/SidebarButton.svelte index b5dd119..2f083b0 100644 --- a/src/lib/components/ui/sidebar/SidebarButton.svelte +++ b/src/lib/components/ui/sidebar/SidebarButton.svelte @@ -15,9 +15,8 @@ import { Button, type Props } from '$lib/components/ui/button' import { cn } from '$lib/utils.js' - type $$Props = Props & { disabled?: boolean | undefined | null } + type $$Props = Props export let href: string | null | undefined = undefined - export let disabled: $$Props['disabled'] = undefined function matchPath (path: string, page: { url: URL }) { return page.url.pathname.startsWith(path) diff --git a/src/lib/modules/anilist/client.ts b/src/lib/modules/anilist/client.ts index 38bfe76..4bd7fd0 100644 --- a/src/lib/modules/anilist/client.ts +++ b/src/lib/modules/anilist/client.ts @@ -5,8 +5,9 @@ import { refocusExchange } from '@urql/exchange-refocus' import { Client, fetchExchange, queryStore, type OperationResultState, gql as _gql } from '@urql/svelte' import Bottleneck from 'bottleneck' import lavenshtein from 'js-levenshtein' -import { readable, writable, type Writable } from 'simple-store-svelte' -import { derived } from 'svelte/store' +import { writable as _writable } from 'simple-store-svelte' +import { derived, readable, writable, type Writable } from 'svelte/store' +import { toast } from 'svelte-sonner' import gql from './gql' import { CommentFrag, Comments, CustomLists, DeleteEntry, DeleteThreadComment, Entry, Following, FullMedia, FullMediaList, IDMedia, SaveThreadComment, Schedule, Search, ThreadFrag, Threads, ToggleFavourite, ToggleLike, UserLists, Viewer } from './queries' @@ -293,6 +294,7 @@ class AnilistClient { } setRateLimit (sec: number) { + toast.error('Anilist Error', { description: 'Rate limit exceeded, retrying in ' + Math.round(sec / 1000) + ' seconds.' }) if (!this.rateLimitPromise) this.rateLimitPromise = sleep(sec).then(() => { this.rateLimitPromise = null }) return sec } @@ -303,8 +305,8 @@ class AnilistClient { if (error.name === 'AbortError') return undefined if (jobInfo.retryCount > 8) return undefined - if (error.message === 'Failed to fetch') return this.setRateLimit(6000) if (!(error instanceof FetchError)) return 0 + if (error.message === 'Failed to fetch' && !error.res.headers.get('retry-after')) return this.setRateLimit(60000) if (error.res.status === 500) return 1000 const time = (parseInt(error.res.headers.get('retry-after') ?? '60') + 1) * 1000 @@ -315,16 +317,17 @@ class AnilistClient { this.continueIDs.subscribe(() => undefined) } - viewer = writable(safeLocalStorage('ALViewer')) + viewer = _writable(safeLocalStorage('ALViewer')) userlists = derived>>(this.viewer, (store, set) => { return queryStore({ client: this.client, query: UserLists, variables: { id: store?.viewer?.id } }).subscribe(set) }) - // these should be optimised to be called with ids.slice(index, index + perPage) + // WARN: these 3 sections are hacky, i use oldvalue to prevent re-running loops, I DO NOT KNOW WHY THE LOOPS HAPPEN! + // TODO: these should be optimised to be called with ids.slice(index, index + perPage) continueIDs = readable([], set => { let oldvalue: number[] = [] - this.userlists.subscribe(values => { + const sub = this.userlists.subscribe(values => { if (!values.data?.MediaListCollection?.lists) return [] const mediaList = values.data.MediaListCollection.lists.reduce['MediaListCollection']>['lists']>[0]>['entries']>>((filtered, list) => { return (list?.status === 'CURRENT' || list?.status === 'REPEATING') ? filtered.concat(list.entries) : filtered @@ -340,12 +343,13 @@ class AnilistClient { oldvalue = ids set(ids) }) + return sub }) - // this needs to be called with onList: false + // TODO: this needs to be called with onList: false sequelIDs = readable([], set => { let oldvalue: number[] = [] - this.userlists.subscribe(values => { + const sub = this.userlists.subscribe(values => { if (!values.data?.MediaListCollection?.lists) return [] const mediaList = values.data.MediaListCollection.lists.find(list => list?.status === 'COMPLETED')?.entries if (!mediaList) return [] @@ -358,6 +362,22 @@ class AnilistClient { oldvalue = ids set(ids) }) + return sub + }) + + planningIDs = readable([], set => { + let oldvalue: number[] = [] + const sub = this.userlists.subscribe(userLists => { + if (!userLists.data?.MediaListCollection?.lists) return [] + const mediaList = userLists.data.MediaListCollection.lists.find(list => list?.status === 'PLANNING')?.entries + if (!mediaList) return [] + const ids = mediaList.map(entry => entry?.media?.id) as number[] + + if (arrayEqual(oldvalue, ids)) return + oldvalue = ids + set(ids) + }) + return sub }) search (variables: VariablesOf, pause?: boolean) { diff --git a/src/lib/modules/auth/client.ts b/src/lib/modules/auth/client.ts index 58e8f34..c0f43b9 100644 --- a/src/lib/modules/auth/client.ts +++ b/src/lib/modules/auth/client.ts @@ -63,6 +63,12 @@ export default new class AuthAggregator { if (this.anilist()) return client.following(id) } + planningIDs () { + if (this.anilist()) return client.planningIDs + + return client.planningIDs + } + continueIDs () { if (this.anilist()) return client.continueIDs diff --git a/src/lib/modules/settings/defaults.ts b/src/lib/modules/settings/defaults.ts index d978b93..f433525 100644 --- a/src/lib/modules/settings/defaults.ts +++ b/src/lib/modules/settings/defaults.ts @@ -36,7 +36,7 @@ export default { idleAnimation: true, enableExternal: false, playerPath: '', - playerSeek: 2, + playerSeek: '2', playerSkip: false, playerSkipFiller: false, minimalPlayerUI: false diff --git a/src/routes/app/anime/[id]/+page.svelte b/src/routes/app/anime/[id]/+page.svelte index 8278aba..ae7bbd1 100644 --- a/src/routes/app/anime/[id]/+page.svelte +++ b/src/routes/app/anime/[id]/+page.svelte @@ -74,7 +74,9 @@ {#key mediaID} - + {#if value === 'threads'} + + {/if} {/key} diff --git a/src/routes/app/home/+page.svelte b/src/routes/app/home/+page.svelte index a7939de..740630d 100644 --- a/src/routes/app/home/+page.svelte +++ b/src/routes/app/home/+page.svelte @@ -1,9 +1,9 @@