mirror of
https://github.com/rommapp/romm.git
synced 2026-12-04 21:02:21 +01:00
refactor(streaming): type a claim's 409 detail in one place
The player and the desktop each spelled the busy-container detail inline, and the two copies had already drifted.
This commit is contained in:
@@ -80,6 +80,16 @@ export function isMemoryCardImportDetail(
|
||||
);
|
||||
}
|
||||
|
||||
/** Body of the 409 a claim returns when the container is taken. The route
|
||||
* raises it as a plain detail dict, so it has no generated schema. */
|
||||
export interface ContainerBusyDetail {
|
||||
message: string;
|
||||
draining: boolean;
|
||||
/** The game holding it, null when the caller may not see which. */
|
||||
rom_name: string | null;
|
||||
claimed_at: string | null;
|
||||
}
|
||||
|
||||
// ── Requests ──────────────────────────────────────────────────────────────────
|
||||
|
||||
async function fetchConfig() {
|
||||
|
||||
@@ -14,7 +14,9 @@ import { computed, onMounted, ref } from "vue";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { onBeforeRouteLeave, useRoute, useRouter } from "vue-router";
|
||||
import { ROUTES } from "@/plugins/router";
|
||||
import streamingApi from "@/services/api/streaming";
|
||||
import streamingApi, {
|
||||
type ContainerBusyDetail,
|
||||
} from "@/services/api/streaming";
|
||||
import { type SessionTermination, useStreamingStore } from "@/stores/streaming";
|
||||
import StreamStage from "@/v2/components/Player/StreamStage.vue";
|
||||
import { useConfirm } from "@/v2/composables/useConfirm";
|
||||
@@ -70,10 +72,7 @@ async function openDesktop(): Promise<void> {
|
||||
? err.response?.data?.detail
|
||||
: undefined;
|
||||
if (status === 409) {
|
||||
const busy = detail as {
|
||||
draining?: boolean;
|
||||
rom_name?: string | null;
|
||||
} | null;
|
||||
const busy = detail as ContainerBusyDetail | null;
|
||||
// A drain marker is nobody's claim: the container comes free on its own
|
||||
// once the previous session has finished saving.
|
||||
if (busy?.draining)
|
||||
|
||||
@@ -42,6 +42,7 @@ import { onBeforeRouteLeave, useRoute, useRouter } from "vue-router";
|
||||
import type { SaveSchema, UserStateSchema } from "@/__generated__";
|
||||
import romApi from "@/services/api/rom";
|
||||
import streamingApi, {
|
||||
type ContainerBusyDetail,
|
||||
isMemoryCardImportDetail,
|
||||
type LaunchFailed,
|
||||
type LaunchPhase,
|
||||
@@ -905,11 +906,7 @@ async function onPlay(cardImport?: MemoryCardImport): Promise<void> {
|
||||
errorType.value = "occupied";
|
||||
const busy =
|
||||
detail && typeof detail === "object"
|
||||
? (detail as {
|
||||
rom_name: string | null;
|
||||
claimed_at: string | null;
|
||||
draining?: boolean;
|
||||
})
|
||||
? (detail as ContainerBusyDetail)
|
||||
: null;
|
||||
// A draining container is nobody's: the previous session is over and its
|
||||
// exit state is still being collected, so there is no holder to name.
|
||||
|
||||
Reference in New Issue
Block a user