feat: update types for rom handling in QR dialog and related components

This commit is contained in:
zurdi
2026-05-27 19:54:56 +00:00
parent 07c536ad79
commit f09515e4fa
6 changed files with 19 additions and 12 deletions

View File

@@ -8,7 +8,7 @@ import GameCard from "@/components/common/Game/Card/Base.vue";
import RDialog from "@/components/common/RDialog.vue";
import romApi, { type UpdateRom } from "@/services/api/rom";
import storeHeartbeat from "@/stores/heartbeat";
import storeRoms, { type SimpleRom } from "@/stores/roms";
import storeRoms, { type DetailedRom, type SimpleRom } from "@/stores/roms";
import storeUpload from "@/stores/upload";
import type { Events } from "@/types/emitter";
import { formatBytes } from "@/utils";
@@ -33,9 +33,12 @@ const validForm = ref(false);
const showConfirmDeleteManual = ref(false);
const emitter = inject<Emitter<Events>>("emitter");
// `files` only ships on DetailedRom; `rom` is reassigned to the detailed
// payload returned by the update/refresh API calls. Mirror the cast used
// by `getNintendoDSFiles` in utils.
const soundtrackTracks = computed(
() =>
rom.value?.files
(rom.value as DetailedRom | null)?.files
?.filter((f) => f.category === "soundtrack")
.slice()
.sort((a, b) => a.file_name.localeCompare(b.file_name)) ?? [],

View File

@@ -4,16 +4,16 @@ import qrcode from "qrcode";
import { inject, nextTick, ref } from "vue";
import { useDisplay } from "vuetify";
import RDialog from "@/components/common/RDialog.vue";
import type { DetailedRom } from "@/stores/roms";
import type { SimpleRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import { getNintendoDSFiles, getDownloadLink, isNintendoDSFile } from "@/utils";
const { lgAndUp } = useDisplay();
const show = ref(false);
const emitter = inject<Emitter<Events>>("emitter");
const rom = ref<DetailedRom>({} as DetailedRom);
const rom = ref<SimpleRom>({} as SimpleRom);
emitter?.on("showQRCodeDialog", async (romToView: DetailedRom) => {
emitter?.on("showQRCodeDialog", async (romToView: SimpleRom) => {
show.value = true;
rom.value = romToView;

View File

@@ -90,7 +90,10 @@ export type Events = {
filterRoms: null;
firmwareDrawerShow: null;
sortBarShow: null;
showQRCodeDialog: DetailedRom;
// The QR dialog only reads SimpleRom fields (name, fs_name, extension)
// and the NDS/download helpers all accept SimpleRom, so gallery surfaces
// (which only ever hold SimpleRom) can trigger it too.
showQRCodeDialog: SimpleRom;
selectSaveDialog: DetailedRom;
selectStateDialog: DetailedRom;
saveSelected: SaveSchema;

View File

@@ -348,7 +348,6 @@ onBeforeUnmount(() => {
v-for="provider in providers"
:key="provider.key"
class="game-list-row__provider"
:title="provider.title"
:style="provider.bg ? { background: provider.bg } : undefined"
>
<img
@@ -357,6 +356,11 @@ onBeforeUnmount(() => {
width="14"
height="14"
/>
<RTooltip
activator="parent"
:text="provider.title"
location="top"
/>
</span>
</div>
</div>

View File

@@ -41,10 +41,7 @@ const artHeight = computed(() =>
<template>
<div
class="r-gcs"
:class="[
size !== 'md' && `r-gcs--size-${size}`,
{ 'r-gcs--hero': hero },
]"
:class="[size !== 'md' && `r-gcs--size-${size}`, { 'r-gcs--hero': hero }]"
>
<RSkeletonBlock
:width="artWidth"

View File

@@ -145,12 +145,12 @@ const syntheticRom = computed<SimpleRom>(() => ({
has_simple_single_file: false,
has_nested_single_file: false,
has_multiple_files: false,
files: [],
full_path: "",
created_at: "",
updated_at: "",
missing_from_fs: false,
has_notes: false,
sibling_ids: [],
siblings: [],
rom_user: EMPTY_USER,
merged_screenshots: [],