mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 19:36:36 +08:00
b2ccd04844
The DLNA device list endpoint could return {"devices":null} in two cases:
the SSDP-failure path returned a nil slice, and the cached path copied an
empty cache via append([]DLNADevice(nil), cache...) which also yields nil.
The web UI reads res.devices.length, so a null devices field crashed the
DLNA page to a white screen. Return non-nil slices in both paths and guard
the frontend with a null coalesce. Adds a regression test.
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
24 lines
582 B
TypeScript
24 lines
582 B
TypeScript
import { api } from './client'
|
|
|
|
export interface DLNADevice {
|
|
udn: string
|
|
friendly_name: string
|
|
manufacturer: string
|
|
model_name: string
|
|
location: string
|
|
control_url: string
|
|
ip_address: string
|
|
}
|
|
|
|
export const dlnaAPI = {
|
|
list: (force = false) =>
|
|
api
|
|
.get<{ devices: DLNADevice[] | null }>('/dlna/devices', { params: { force: force ? 'true' : '' } })
|
|
.then((r) => r.data.devices ?? []),
|
|
|
|
cast: (controlURL: string, mediaURL: string) =>
|
|
api
|
|
.post('/dlna/cast', { control_url: controlURL, media_url: mediaURL })
|
|
.then((r) => r.data),
|
|
}
|