mirror of
https://github.com/rommapp/romm.git
synced 2026-12-02 18:18:47 +01:00
refactor based on bot review
This commit is contained in:
@@ -389,23 +389,15 @@ async function boot() {
|
||||
platformId: rom.platform_id,
|
||||
});
|
||||
|
||||
function getFirmware(): FirmwareSchema | null {
|
||||
// Check for last-used bios file
|
||||
const firmwareFromStorage = playerStorage.biosId.value
|
||||
? firmware.find((f) => f.id === parseInt(playerStorage.biosId.value!))
|
||||
: null;
|
||||
const biosFromStorage = playerStorage.biosId.value
|
||||
? firmware.find((f) => f.id === parseInt(playerStorage.biosId.value!))
|
||||
: undefined;
|
||||
|
||||
if (firmwareFromStorage) return firmwareFromStorage;
|
||||
const biosFromConfig = coreOptions["bios_file"]
|
||||
? firmware.find((f) => f.file_name === coreOptions["bios_file"])
|
||||
: undefined;
|
||||
|
||||
// Use default bios file if set in config.yml
|
||||
if (!coreOptions["bios_file"]) return null;
|
||||
const firmwareFromConfig =
|
||||
firmware.find((f) => f.file_name === coreOptions["bios_file"]) ?? null;
|
||||
|
||||
return firmwareFromConfig;
|
||||
}
|
||||
|
||||
const bios = getFirmware();
|
||||
const bios = biosFromStorage ?? biosFromConfig ?? null;
|
||||
window.EJS_biosUrl = bios
|
||||
? `/api/firmware/${bios.id}/content/${bios.file_name}`
|
||||
: "";
|
||||
|
||||
@@ -212,23 +212,23 @@ onMounted(async () => {
|
||||
selectedCore.value = supportedCores.value[0];
|
||||
}
|
||||
|
||||
// Use default bios file if set in config.yml
|
||||
const coreOptions = configStore.getEJSCoreOptions(selectedCore.value);
|
||||
if (coreOptions["bios_file"]) {
|
||||
selectedFirmware.value =
|
||||
firmwareOptions.value.find(
|
||||
(f) => f.file_name === coreOptions["bios_file"],
|
||||
) ?? null;
|
||||
}
|
||||
|
||||
const storedBiosID = localStorage.getItem(
|
||||
`player:${rom.value.platform_slug}:bios_id`,
|
||||
);
|
||||
if (storedBiosID) {
|
||||
selectedFirmware.value =
|
||||
firmwareOptions.value.find((f) => f.id === parseInt(storedBiosID)) ??
|
||||
null;
|
||||
}
|
||||
|
||||
const biosFromStorage = storedBiosID
|
||||
? firmwareOptions.value.find((f) => f.id === parseInt(storedBiosID))
|
||||
: undefined;
|
||||
|
||||
// Use default bios file if set in config.yml
|
||||
const biosFromConfig = coreOptions["bios_file"]
|
||||
? firmwareOptions.value.find(
|
||||
(f) => f.file_name === coreOptions["bios_file"],
|
||||
)
|
||||
: undefined;
|
||||
|
||||
selectedFirmware.value = biosFromStorage ?? biosFromConfig ?? null;
|
||||
});
|
||||
|
||||
onBeforeUnmount(async () => {
|
||||
|
||||
Reference in New Issue
Block a user