chore: use simple if/else instead of ternary operator in KvmCard

This commit is contained in:
Siyuan Miao 2025-11-24 16:33:53 +01:00
parent 3d6e88caad
commit afa3cf2484
1 changed files with 5 additions and 4 deletions

View File

@ -53,7 +53,7 @@ export default function KvmCard({
id: string; id: string;
online: boolean; online: boolean;
lastSeen: Date | null; lastSeen: Date | null;
appVersion: string; appVersion?: string;
}) { }) {
/** /**
* Constructs the URL for connecting to this KVM device's interface. * 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"; const BACKWARDS_COMPATIBLE_VERSION = "0.5.0";
// Use device version if valid and >= 0.5.0, otherwise fall back to backwards-compatible version // Use device version if valid and >= 0.5.0, otherwise fall back to backwards-compatible version
const shouldUseDeviceVersion = let version = BACKWARDS_COMPATIBLE_VERSION;
semver.valid(appVersion) && semver.gte(appVersion, BACKWARDS_COMPATIBLE_VERSION); if (appVersion && semver.valid(appVersion) && semver.gte(appVersion, BACKWARDS_COMPATIBLE_VERSION)) {
const version = shouldUseDeviceVersion ? appVersion : BACKWARDS_COMPATIBLE_VERSION; version = appVersion;
}
return new URL(`/v/${version}/devices/${id}`, window.location.origin).toString(); return new URL(`/v/${version}/devices/${id}`, window.location.origin).toString();
}, [appVersion, id]); }, [appVersion, id]);