fix(details): ask saves only for a slot when uploading

The core picker is for states; a save upload now shows just the slot
picker and never tags an emulator.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
zurdi
2026-09-16 04:06:51 +02:00
parent e9ee27d522
commit f155a704fc
3 changed files with 20 additions and 18 deletions

View File

@@ -130,17 +130,17 @@ const subtabDefs = computed<SubtabDef[]>(() => [
]);
// ---------- Upload / refresh plumbing ----------
// Every upload goes through the dialog, which asks for the slot and the
// core; dropped files land in it pre-picked.
// Every upload goes through the dialog, which asks saves for a slot and
// states for a core; dropped files land in it pre-picked.
const uploadDialog = ref<{ type: UploadAssetType; files: File[] } | null>(null);
function openUpload(type: UploadAssetType, files: File[] = []) {
uploadDialog.value = { type, files };
}
// The platform's cores plus whatever the existing assets were tagged with.
// The platform's cores plus whatever the existing states were tagged with.
const uploadCores = computed(() => {
const cores = new Set(getSupportedEJSCores(props.rom.platform_slug));
for (const asset of [...mySaves.value, ...myStates.value]) {
if (asset.emulator) cores.add(asset.emulator);
for (const state of myStates.value) {
if (state.emulator) cores.add(state.emulator);
}
return [...cores];
});
@@ -155,7 +155,7 @@ async function onUploadSubmit({
}) {
const type = uploadDialog.value?.type;
uploadDialog.value = null;
if (type === "save") await onSaveUpload(files, slot, emulator);
if (type === "save") await onSaveUpload(files, slot);
else if (type === "state") await onStateUpload(files, emulator);
}
const uploadingSaves = ref(false);
@@ -169,11 +169,7 @@ async function refreshRom() {
await refetchRom(props.rom.id);
}
async function onSaveUpload(
files: File[],
slot: string | null,
emulator: string | null,
) {
async function onSaveUpload(files: File[], slot: string | null) {
if (files.length === 0 || uploadingSaves.value) return;
uploadingSaves.value = true;
@@ -182,7 +178,6 @@ async function onSaveUpload(
rom: props.rom,
savesToUpload: files.map((saveFile) => ({ saveFile })),
slot: slot ?? undefined,
emulator: emulator ?? undefined,
});
const successful = results.filter((r) => r.status === "fulfilled").length;
const failed = results.length - successful;

View File

@@ -151,15 +151,15 @@ describe("UploadAssetDialog", () => {
expect(await submitted(wrapper)).toMatchObject({ slot: "main_quest" });
});
it("names a new slot and tags the core", async () => {
it("names a new slot and asks saves for nothing else", async () => {
const wrapper = mountDialog("save", [new File(["x"], "a.srm")]);
expect(wrapper.findAll("select")).toHaveLength(1);
await choose(wrapper, 0, 3);
await wrapper.get("input.slot-name").setValue(" speedrun ");
await choose(wrapper, 1, 1);
expect(await submitted(wrapper)).toMatchObject({
slot: "speedrun",
emulator: "mgba",
emulator: null,
});
});
@@ -176,6 +176,12 @@ describe("UploadAssetDialog", () => {
const wrapper = mountDialog("state", [new File(["x"], "a.state")]);
expect(wrapper.findAll("select")).toHaveLength(1);
expect(wrapper.findAll("option").map((o) => o.text())).toEqual([
"play.any-core",
"mgba",
"builtin",
]);
await choose(wrapper, 0, 2);
expect(await submitted(wrapper)).toMatchObject({
slot: null,

View File

@@ -1,5 +1,5 @@
<script setup lang="ts">
// UploadAssetDialog: pick the slot (saves) and the core the files were made
// UploadAssetDialog: pick the slot for saves, or the core states were made
// with, then the files to send. The Save data tab owns the upload, and
// closes the dialog first.
import {
@@ -37,7 +37,7 @@ const props = defineProps<{
type: UploadAssetType;
/** Own saves, whose slots the picker offers. */
saves: Pick<SaveSchema, "slot">[];
/** Cores the files may have been made with. */
/** Cores the states may have been made with. */
cores: string[];
/** Files dropped on the tab, already picked when the dialog opens. */
initialFiles: File[];
@@ -114,7 +114,7 @@ async function submit() {
props.type === "save" && picked.kind !== "none"
? chosenSlot(picked, newSlotName.value)
: null,
emulator: core.value || null,
emulator: props.type === "state" ? core.value || null : null,
});
}
</script>
@@ -154,6 +154,7 @@ async function submit() {
autocomplete="off"
/>
<RSelect
v-if="type === 'state'"
v-model="core"
:items="coreItems"
:label="t('common.core')"