fix: rating scale on kitsu, local and MAL

fix: initial focus element when using keyboard navigation
This commit is contained in:
ThaUnknown 2025-07-17 13:08:17 +02:00
parent 1c39526afb
commit d8ebb596e5
No known key found for this signature in database
6 changed files with 14 additions and 7 deletions

View file

@ -3,7 +3,7 @@
import Heart from 'lucide-svelte/icons/heart'
import House from 'lucide-svelte/icons/house'
import LogIn from 'lucide-svelte/icons/log-in'
import MessagesSquare from 'lucide-svelte/icons/messages-square'
// import MessagesSquare from 'lucide-svelte/icons/messages-square'
import Play from 'lucide-svelte/icons/play'
import Search from 'lucide-svelte/icons/search'
import Settings from 'lucide-svelte/icons/settings'

View file

@ -79,7 +79,7 @@ export interface KEntry {
startedAt?: string // Date
finishedAt?: string
rating?: string
ratingTwenty?: null
ratingTwenty?: string
}
export interface Fav {

View file

@ -455,7 +455,8 @@ export default new class KitsuSync {
}
if (variables.progress) kitsuEntryVariables.progress = variables.progress
if (variables.score) kitsuEntryVariables.rating = (variables.score < 2 ? undefined : variables.score.toString())
// kitsu's rating is 2-20... aka 2 = 10, 20 = 100, insane, normalize this
if (variables.score) kitsuEntryVariables.ratingTwenty = variables.score < 10 ? undefined : (variables.score / 5).toString()
if (variables.repeat) kitsuEntryVariables.reconsumeCount = variables.repeat
if (kitsuEntry) {

View file

@ -123,10 +123,13 @@ export default new class LocalSync {
status: null
}
const keys = ['status', 'score', 'repeat', 'progress'] as const
const keys = ['status', 'score', 'repeat', 'progress'] as Array<keyof typeof variables>
for (const key of keys) {
let value = variables[key]
// @ts-expect-error idk how to fix this tbf
entry.mediaListEntry[key] = variables[key] ?? entry.mediaListEntry[key] ?? null
if (key === 'score' && value != null) value /= 10
// @ts-expect-error idk how to fix this tbf
entry.mediaListEntry[key] = value ?? entry.mediaListEntry[key] ?? null
}
return { ...entries, [variables.id]: entry }
})

View file

@ -440,7 +440,7 @@ export default new class MALSync {
}
if (variables.progress) body.num_watched_episodes = variables.progress
if (variables.score) body.score = variables.score
if (variables.score) body.score = variables.score / 10
if (variables.repeat) body.num_times_rewatched = variables.repeat
const res = await this._patch<MALStatus>(`${ENDPOINTS.API_ANIME}/${malId}/my_list_status`, body)

View file

@ -218,7 +218,10 @@ function getElementsInDesiredDirection (keyboardFocusable: ElementPosition[], cu
*/
function navigateDPad (direction = 'up') {
const keyboardFocusable = getFocusableElementPositions()
const currentElement = !document.activeElement || document.activeElement === document.body ? keyboardFocusable[0]! : getElementPosition(document.activeElement as HTMLElement)
const nofocus = !document.activeElement || document.activeElement === document.body
const currentElement = nofocus ? keyboardFocusable[0]! : getElementPosition(document.activeElement as HTMLElement)
if (nofocus) return focusElement(currentElement.element)
// allow overrides via data attributes ex: <div data-up="#id, #id2"?> but order them, as querySelectorAll returns them in order of appearance rather than order of selectors
for (const selector of currentElement.element.dataset[direction]?.split(',') ?? []) {