From afa3cf2484fe8b2eae0b697a59e33d1d4bd06c8a Mon Sep 17 00:00:00 2001 From: Siyuan Miao Date: Mon, 24 Nov 2025 16:33:53 +0100 Subject: [PATCH] chore: use simple if/else instead of ternary operator in KvmCard --- ui/src/components/KvmCard.tsx | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ui/src/components/KvmCard.tsx b/ui/src/components/KvmCard.tsx index 078cee1e..8d79d0e1 100644 --- a/ui/src/components/KvmCard.tsx +++ b/ui/src/components/KvmCard.tsx @@ -53,7 +53,7 @@ export default function KvmCard({ id: string; online: boolean; lastSeen: Date | null; - appVersion: string; + appVersion?: string; }) { /** * Constructs the URL for connecting to this KVM device's interface. @@ -66,9 +66,10 @@ export default function KvmCard({ const BACKWARDS_COMPATIBLE_VERSION = "0.5.0"; // Use device version if valid and >= 0.5.0, otherwise fall back to backwards-compatible version - const shouldUseDeviceVersion = - semver.valid(appVersion) && semver.gte(appVersion, BACKWARDS_COMPATIBLE_VERSION); - const version = shouldUseDeviceVersion ? appVersion : BACKWARDS_COMPATIBLE_VERSION; + let version = BACKWARDS_COMPATIBLE_VERSION; + if (appVersion && semver.valid(appVersion) && semver.gte(appVersion, BACKWARDS_COMPATIBLE_VERSION)) { + version = appVersion; + } return new URL(`/v/${version}/devices/${id}`, window.location.origin).toString(); }, [appVersion, id]);