From e6c5f2a9caa8e434ea49e1e5626e8704757716b1 Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Sun, 12 Feb 2023 09:58:21 +0100 Subject: [PATCH] Fix instance version check --- Packages/Env/Sources/Env/CurrentInstance.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Packages/Env/Sources/Env/CurrentInstance.swift b/Packages/Env/Sources/Env/CurrentInstance.swift index 5d2274f5..443419d8 100644 --- a/Packages/Env/Sources/Env/CurrentInstance.swift +++ b/Packages/Env/Sources/Env/CurrentInstance.swift @@ -9,17 +9,29 @@ public class CurrentInstance: ObservableObject { private var client: Client? public static let shared = CurrentInstance() + + private var version: Float { + if let stringVersion = instance?.version { + if stringVersion.utf8.count > 2 { + return Float(stringVersion.prefix(3)) ?? 0 + } else { + return Float(stringVersion.prefix(1)) ?? 0 + } + } + return 0 + } + public var isFiltersSupported: Bool { - instance?.version.hasPrefix("4") == true + version >= 4 } public var isEditSupported: Bool { - instance?.version.hasPrefix("4") == true + version >= 4 } public var isEditAltTextSupported: Bool { - instance?.version.hasPrefix("4.1") == true + version >= 4.1 } private init() {}