From b829f9ba3e772216342052023c91d6708e6e1a5f Mon Sep 17 00:00:00 2001 From: chahinebrini Date: Wed, 17 Jun 2026 03:06:38 +0200 Subject: [PATCH] fix(magic): match current device by session deviceId, remove confusing overall status card --- .../app/composables/useDeviceStatus.ts | 14 +++- apps/rebreak-magic/app/pages/status.vue | 70 +------------------ 2 files changed, 14 insertions(+), 70 deletions(-) diff --git a/apps/rebreak-magic/app/composables/useDeviceStatus.ts b/apps/rebreak-magic/app/composables/useDeviceStatus.ts index 81efc6e..5a8257a 100644 --- a/apps/rebreak-magic/app/composables/useDeviceStatus.ts +++ b/apps/rebreak-magic/app/composables/useDeviceStatus.ts @@ -37,11 +37,19 @@ export function useDeviceStatus( devices: Ref, localHostname: Ref, iphone: Ref, + currentDeviceId?: Ref, ) { - const currentBackendDevice = computed(() => { - if (!localHostname.value) return null; + function isCurrentDevice(d: MagicDeviceInfo): boolean { + if (currentDeviceId?.value) { + return d.deviceId === currentDeviceId.value; + } + if (!localHostname.value) return false; const local = normalizeHostname(localHostname.value); - const found = devices.value.find((d) => normalizeHostname(d.hostname) === local); + return normalizeHostname(d.hostname) === local; + } + + const currentBackendDevice = computed(() => { + const found = devices.value.find(isCurrentDevice); if (!found) return null; return { deviceId: found.deviceId, diff --git a/apps/rebreak-magic/app/pages/status.vue b/apps/rebreak-magic/app/pages/status.vue index cfac7dd..56b51d9 100644 --- a/apps/rebreak-magic/app/pages/status.vue +++ b/apps/rebreak-magic/app/pages/status.vue @@ -33,41 +33,6 @@
- - -
-
- -
-
-
-

{{ protection.status.value.label }}

- - {{ overallBadgeLabel }} - -
-

{{ protection.status.value.message }}

-
- -
-
-

Aktives Gerät

@@ -169,6 +134,8 @@ const devices = useMagicDevices(); const iphone = useIphoneDevice(); const protection = useProtectionStatus(); +const currentDeviceId = computed(() => session.value?.deviceId ?? null); + const profile = ref(null); const loading = ref(false); const error = ref(null); @@ -178,34 +145,7 @@ const platformInfo = ref<{ platform: string } | null>(null); // Share localHostname from protection composable with device status logic. const localHostname = protection.localHostname; -const { currentBackendDevice, otherDevices, iosStars } = useDeviceStatus(devices, localHostname, iphone); - -const statusCardClass = computed(() => { - switch (protection.status.value.overall) { - case "protected": return "from-emerald-500 to-teal-500"; - case "partial": return "from-amber-500 to-orange-500"; - case "unprotected": return "from-slate-400 to-slate-500"; - default: return "from-blue-500 to-indigo-500"; - } -}); - -const badgeColorForOverall = computed(() => { - switch (protection.status.value.overall) { - case "protected": return "success"; - case "partial": return "warning"; - case "unprotected": return "neutral"; - default: return "primary"; - } -}); - -const overallBadgeLabel = computed(() => { - switch (protection.status.value.overall) { - case "protected": return "Aktiv"; - case "partial": return "Teilweise"; - case "unprotected": return "Inaktiv"; - default: return "Unbekannt"; - } -}); +const { currentBackendDevice, otherDevices, iosStars } = useDeviceStatus(devices, localHostname, iphone, currentDeviceId); onMounted(async () => { await loadProfile(); @@ -239,10 +179,6 @@ async function refresh() { } } -function formatTime(date: Date) { - return date.toLocaleTimeString("de-DE", { hour: "2-digit", minute: "2-digit", second: "2-digit" }); -} - function openDevice(device: ComputedDevice) { selectedDevice.value = device; sheetOpen.value = true;