mirror of
https://github.com/truewhile/MeBox.git
synced 2026-09-29 11:36:36 +08:00
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:
+2
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user