fix(dlna): always return non-nil device slice so API serializes [] not null

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>
This commit is contained in:
soldosluka857
2026-05-30 04:34:12 +00:00
committed by Shuke
parent 7e83047fdb
commit b2ccd04844
3 changed files with 44 additions and 5 deletions
+2 -2
View File
@@ -13,8 +13,8 @@ export interface DLNADevice {
export const dlnaAPI = {
list: (force = false) =>
api
.get<{ devices: DLNADevice[] }>('/dlna/devices', { params: { force: force ? 'true' : '' } })
.then((r) => r.data.devices),
.get<{ devices: DLNADevice[] | null }>('/dlna/devices', { params: { force: force ? 'true' : '' } })
.then((r) => r.data.devices ?? []),
cast: (controlURL: string, mediaURL: string) =>
api