mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-03-29 06:28:43 +00:00
fix: anime incorrectly marked as completed when anilist doesn't provide an episode count
This commit is contained in:
parent
a5fa723db1
commit
0db7c3bbd4
3 changed files with 17 additions and 12 deletions
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ui",
|
||||
"version": "6.3.64",
|
||||
"version": "6.3.65",
|
||||
"license": "BUSL-1.1",
|
||||
"private": true,
|
||||
"packageManager": "pnpm@9.14.4",
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
import { authAggregator } from '../auth'
|
||||
|
||||
import type { ScheduleMedia } from './queries'
|
||||
import type { Media } from './types'
|
||||
import type { Episode, Episodes } from '../anizip/types'
|
||||
|
|
@ -93,7 +95,7 @@ export function episodes (media: Pick<Media, 'aired' | 'notaired' | 'episodes' |
|
|||
|
||||
const upcoming = media.aired?.n?.[media.aired.n.length - 1]?.e ?? 0
|
||||
const past = media.notaired?.n?.[media.notaired.n.length - 1]?.e ?? 0
|
||||
const progress = media.mediaListEntry?.progress ?? 0
|
||||
const progress = authAggregator.mediaListEntry(media)?.progress ?? 0
|
||||
|
||||
return Math.max(upcoming, past, progress)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -106,15 +106,18 @@ export default new class AuthAggregator {
|
|||
|
||||
watch (media: Media, progress: number) {
|
||||
// TODO: auto re-watch status
|
||||
// if (media.status !== 'FINISHED' && media.status !== 'RELEASING') return // this turned out to be a bad idea, anilist sometimes delays status changes by up to a day... yikes
|
||||
const totalEps = episodes(media) ?? 1 // episodes or movie which is single episode
|
||||
if (totalEps < progress) return // woah, bad data from resolver?!
|
||||
|
||||
const currentProgress = media.mediaListEntry?.progress ?? 0
|
||||
if (currentProgress >= progress) return
|
||||
|
||||
// there's an edge case here that episodes returns 1, because anilist doesn't have episode count for an airing show without an expected end date
|
||||
// this can set a media to completed when it shouldn't be, so we check if the media is finished or has episodes
|
||||
const canBeCompleted = media.status === 'FINISHED' || media.episodes != null
|
||||
|
||||
const status =
|
||||
totalEps === progress
|
||||
totalEps === progress && canBeCompleted
|
||||
? 'COMPLETED'
|
||||
: media.mediaListEntry?.status === 'REPEATING' ? 'REPEATING' : 'CURRENT'
|
||||
|
||||
|
|
@ -124,26 +127,26 @@ export default new class AuthAggregator {
|
|||
}
|
||||
|
||||
delete (media: Media) {
|
||||
const syncSettings = get(this.syncSettings)
|
||||
const sync = get(this.syncSettings)
|
||||
|
||||
return Promise.allSettled([
|
||||
this.anilist() && syncSettings.al && client.deleteEntry(media),
|
||||
this.kitsu() && syncSettings.kitsu && kitsu.deleteEntry(media),
|
||||
syncSettings.local && local.deleteEntry(media)
|
||||
sync.al && this.anilist() && client.deleteEntry(media),
|
||||
sync.kitsu && this.kitsu() && kitsu.deleteEntry(media),
|
||||
sync.local && local.deleteEntry(media)
|
||||
])
|
||||
}
|
||||
|
||||
entry (variables: VariablesOf<typeof Entry>) {
|
||||
const syncSettings = get(this.syncSettings)
|
||||
const sync = get(this.syncSettings)
|
||||
variables.lists ??= []
|
||||
if (!variables.lists.includes('Watched using Hayase')) {
|
||||
variables.lists.push('Watched using Hayase')
|
||||
}
|
||||
|
||||
return Promise.allSettled([
|
||||
this.anilist() && syncSettings.al && client.entry(variables),
|
||||
this.kitsu() && syncSettings.kitsu && kitsu.entry(variables),
|
||||
syncSettings.local && local.entry(variables)
|
||||
sync.al && this.anilist() && client.entry(variables),
|
||||
sync.kitsu && this.kitsu() && kitsu.entry(variables),
|
||||
sync.local && local.entry(variables)
|
||||
])
|
||||
}
|
||||
}()
|
||||
|
|
|
|||
Loading…
Reference in a new issue