mirror of
https://github.com/rommapp/romm.git
synced 2026-06-29 07:16:28 +00:00
feat: update types for rom handling in QR dialog and related components
This commit is contained in:
@@ -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)) ?? [],
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
5
frontend/src/types/emitter.d.ts
vendored
5
frontend/src/types/emitter.d.ts
vendored
@@ -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;
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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: [],
|
||||
|
||||
Reference in New Issue
Block a user