Fix frontend type mismatches

This commit is contained in:
2026-05-30 04:52:59 +00:00
parent 7a0247d78f
commit c9d2bcfdcc
3 changed files with 25 additions and 15 deletions
+5 -5
View File
@@ -227,7 +227,7 @@ import ReleaseActionMenu from "./ReleaseActionMenu.vue"
import { sortTorrentsByPreference } from "../composables/useSettings" import { sortTorrentsByPreference } from "../composables/useSettings"
const props = defineProps<{ const props = defineProps<{
series: Series series: Series & { root_id?: string | null }
allMovies: MovieUi[] allMovies: MovieUi[]
focusEpisode?: { seasonNumber: number; episodeNumber: number } | null focusEpisode?: { seasonNumber: number; episodeNumber: number } | null
hasResumePosition: (filePath: string | null) => boolean hasResumePosition: (filePath: string | null) => boolean
@@ -737,7 +737,7 @@ function handleOpenFolder(folderPath: string, rootId?: string | null) {
function handleVersionActivate(torrent: Torrent, event: MouseEvent | KeyboardEvent) { function handleVersionActivate(torrent: Torrent, event: MouseEvent | KeyboardEvent) {
if (!torrent.playable_file) return if (!torrent.playable_file) return
const rootId = torrent.root_id || props.series.root_id const rootId = torrent.root_id ?? props.series.root_id ?? null
if (event.altKey) { if (event.altKey) {
handleOpenFolder(torrent.playable_file, rootId) handleOpenFolder(torrent.playable_file, rootId)
return return
@@ -747,7 +747,7 @@ function handleVersionActivate(torrent: Torrent, event: MouseEvent | KeyboardEve
function handleVersionShortcutKeydown(event: KeyboardEvent, torrent: Torrent) { function handleVersionShortcutKeydown(event: KeyboardEvent, torrent: Torrent) {
if (!torrent.playable_file) return if (!torrent.playable_file) return
const rootId = torrent.root_id || props.series.root_id const rootId = torrent.root_id ?? props.series.root_id ?? null
const key = event.key.toLowerCase() const key = event.key.toLowerCase()
if (key === "e" && (event.metaKey || event.ctrlKey)) { if (key === "e" && (event.metaKey || event.ctrlKey)) {
event.preventDefault() event.preventDefault()
@@ -759,7 +759,7 @@ function handleVersionShortcutKeydown(event: KeyboardEvent, torrent: Torrent) {
function handleVersionContextMenu(event: MouseEvent, torrent: Torrent) { function handleVersionContextMenu(event: MouseEvent, torrent: Torrent) {
event.preventDefault() event.preventDefault()
event.stopPropagation() event.stopPropagation()
const rootId = torrent.root_id || props.series.root_id const rootId = torrent.root_id ?? props.series.root_id ?? null
versionActionMenu.value = { versionActionMenu.value = {
visible: true, visible: true,
x: event.clientX, x: event.clientX,
@@ -1013,7 +1013,7 @@ function handleEpisodeHover(eventOrKey: MouseEvent | string, keyOrIsEntering: st
if (isEntering) { if (isEntering) {
hoveredEpisodeAudioKey = key hoveredEpisodeAudioKey = key
videoRefs.value.forEach((v, k) => { videoRefs.value.forEach((_, k) => {
if (k !== key) { if (k !== key) {
rampEpisodeVolume(k, 0) rampEpisodeVolume(k, 0)
} }
+19 -9
View File
@@ -1,5 +1,7 @@
import { shallowRef, readonly, onUnmounted } from "vue" import { shallowRef, readonly, onUnmounted } from "vue"
import type { import type {
CastGender,
CastMember,
Movie, Movie,
MovieUi, MovieUi,
Person, Person,
@@ -162,13 +164,7 @@ export function useMediaWebSocket() {
function normalizeCastMember( function normalizeCastMember(
member: unknown, member: unknown,
people: Map<number, Person>, people: Map<number, Person>,
): { ): CastMember {
name: string
character: string | null
profile_path: string | null
gender: string | null
id: number | null
} {
if (!Array.isArray(member)) { if (!Array.isArray(member)) {
return { return {
name: "", name: "",
@@ -187,7 +183,7 @@ export function useMediaWebSocket() {
name: person?.name || "", name: person?.name || "",
character, character,
profile_path: person?.profile_path || null, profile_path: person?.profile_path || null,
gender: person?.gender || null, gender: person?.gender ?? null,
id, id,
} }
} }
@@ -204,10 +200,24 @@ export function useMediaWebSocket() {
function normalizePerson(member: unknown): Person | null { function normalizePerson(member: unknown): Person | null {
if (!Array.isArray(member)) return null if (!Array.isArray(member)) return null
const gender = normalizeCastGender(member[2])
return { return {
name: typeof member[0] === "string" ? member[0] : "", name: typeof member[0] === "string" ? member[0] : "",
profile_path: typeof member[1] === "string" ? member[1] : null, profile_path: typeof member[1] === "string" ? member[1] : null,
gender: typeof member[2] === "string" ? member[2] : null, gender,
}
}
function normalizeCastGender(value: unknown): CastGender | null {
if (typeof value !== "string") return null
switch (value) {
case "female":
case "male":
case "non_binary":
case "unknown":
return value
default:
return null
} }
} }
+1 -1
View File
@@ -39,7 +39,7 @@ export interface Info {
tagline: string | null tagline: string | null
similar: SimilarMedia[] | null similar: SimilarMedia[] | null
keywords: string[] | null keywords: string[] | null
cast: CastCreditWire[] | null cast: CastMember[] | null
director: string | null director: string | null
creators: string[] | null creators: string[] | null
number_of_seasons: number | null number_of_seasons: number | null