Fix instance version check

This commit is contained in:
Thomas Ricouard 2023-02-12 09:58:21 +01:00
parent a32e4f98bb
commit e6c5f2a9ca
1 changed files with 15 additions and 3 deletions

View File

@ -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() {}