diff --git a/frontend/src/components/Details/ActionBar.vue b/frontend/src/components/Details/ActionBar.vue index 0d3d83e3e..9d201820e 100644 --- a/frontend/src/components/Details/ActionBar.vue +++ b/frontend/src/components/Details/ActionBar.vue @@ -10,7 +10,7 @@ import storeAuth from "@/stores/auth"; import storeDownload from "@/stores/download"; import type { DetailedRom } from "@/stores/roms"; import type { Events } from "@/types/emitter"; -import { getDownloadLink, is3DSCIARom } from "@/utils"; +import { getDownloadLink, isNintendoDSRom } from "@/utils"; const props = defineProps<{ rom: DetailedRom }>(); const downloadStore = storeDownload(); @@ -19,8 +19,8 @@ const qrCodeIcon = ref("mdi-qrcode"); const auth = storeAuth(); const { t } = useI18n(); -const is3DSRom = computed(() => { - return is3DSCIARom(props.rom); +const isNDSRom = computed(() => { + return isNintendoDSRom(props.rom); }); async function copyDownloadLink(rom: DetailedRom) { @@ -84,7 +84,7 @@ async function copyDownloadLink(rom: DetailedRom) { { return props.sizeActionBar === 1 ? "small" : "x-small"; }); -const is3DSRom = computed(() => { - return is3DSCIARom(props.rom); +const isNDSRom = computed(() => { + return isNintendoDSRom(props.rom); }); const isEmulationSupported = computed(() => { @@ -81,7 +81,7 @@ watch(menuOpen, (val) => { @click.prevent /> - + { await nextTick(); - const is3DSFile = is3DSCIAFile(romToView); - const matchingFiles = get3DSCIAFiles(romToView); + const isNDSFile = isNintendoDSFile(romToView); + const matchingFiles = getNintendoDSFiles(romToView); const downloadLink = getDownloadLink({ rom: romToView, - fileIDs: is3DSFile ? [] : [matchingFiles[0].id], + fileIDs: isNDSFile ? [] : [matchingFiles[0].id], }); const qrCode = document.getElementById("qr-code"); diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 68d057c1c..a66142be7 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -668,26 +668,37 @@ export function getStatusKeyForText(text: string | null) { return inverseRomStatusMap[text]; } -export function is3DSCIAFile(rom: SimpleRom): boolean { - return rom.fs_extension.toLowerCase() == "cia"; +export function isNintendoDSFile(rom: SimpleRom): boolean { + return ["cia", "nds", "3ds", "dsi"].includes(rom.fs_extension.toLowerCase()); } -export function get3DSCIAFiles(rom: SimpleRom): RomFileSchema[] { - return rom.files.filter((file) => - file.file_name.toLowerCase().endsWith(".cia"), - ); +export function getNintendoDSFiles(rom: SimpleRom): RomFileSchema[] { + return rom.files.filter((file) => { + const fileName = file.file_name.toLowerCase(); + return ( + fileName.endsWith(".cia") || + fileName.endsWith(".nds") || + fileName.endsWith(".3ds") || + fileName.endsWith(".dsi") + ); + }); } /** - * Check if a ROM is a valid 3DS game + * Check if a ROM is a valid NDS/3DS/DSi game * @param rom The ROM object. - * @returns True if the ROM is a valid 3DS game, false otherwise. + * @returns {boolean} True if the ROM is a valid game, otherwise false. */ -export function is3DSCIARom(rom: SimpleRom): boolean { - if (rom.platform_slug !== "3ds") return false; +export function isNintendoDSRom(rom: SimpleRom): boolean { + if ( + !["3ds", "nds", "new-nintendo-3ds", "nintendo-dsi"].includes( + rom.platform_slug, + ) + ) + return false; - const hasValidExtension = is3DSCIAFile(rom); - const hasValidFile = get3DSCIAFiles(rom).length > 0; + const hasValidExtension = isNintendoDSFile(rom); + const hasValidFile = getNintendoDSFiles(rom).length > 0; return hasValidExtension || hasValidFile; }