From 8851f36f65b61cc1a735fabfbaa1f9cc1f4d2286 Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Fri, 15 May 2026 23:02:26 +0200 Subject: [PATCH] =?UTF-8?q?fix(native):=20protectedDevices=20store=20?= =?UTF-8?q?=E2=80=94=20unwrap=20response=20shape?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Backend GET /api/devices/protected returns: { success, data: { devices, plan, max, isLegend } } apiFetch already unwraps `data`, leaving us with the object { devices, plan, max, isLegend } — not an array. Old code did `Array.isArray(res) ? res : []` on that object, which silently fell through to an empty list. Effect: enrolled protected devices (Mac/Windows) never appeared in the Geräte screen even though the DB row existed and the API responded correctly. Fix: read res.devices instead of assuming the response is the array. --- apps/rebreak-native/stores/protectedDevices.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/rebreak-native/stores/protectedDevices.ts b/apps/rebreak-native/stores/protectedDevices.ts index db96f3b..7b07754 100644 --- a/apps/rebreak-native/stores/protectedDevices.ts +++ b/apps/rebreak-native/stores/protectedDevices.ts @@ -36,8 +36,8 @@ export const useProtectedDevicesStore = create((set, get) load: async () => { set({ loading: true }); try { - const res = await apiFetch('/api/devices/protected'); - set({ devices: Array.isArray(res) ? res : [] }); + const res = await apiFetch<{ devices?: ProtectedDevice[] }>('/api/devices/protected'); + set({ devices: Array.isArray(res?.devices) ? res.devices : [] }); } catch { // endpoint might not be ready yet — keep empty state, screen handles it } finally {