mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2025-01-30 06:15:08 +01:00
32 lines
679 B
Swift
32 lines
679 B
Swift
import Foundation
|
|
import Models
|
|
import Network
|
|
|
|
@MainActor
|
|
public class CurrentInstance: ObservableObject {
|
|
@Published public private(set) var instance: Instance?
|
|
|
|
private var client: Client?
|
|
|
|
public static let shared = CurrentInstance()
|
|
|
|
public var isFiltersSupported: Bool {
|
|
instance?.version.hasPrefix("4") == true
|
|
}
|
|
|
|
public var isEditSupported: Bool {
|
|
instance?.version.hasPrefix("4") == true
|
|
}
|
|
|
|
private init() {}
|
|
|
|
public func setClient(client: Client) {
|
|
self.client = client
|
|
}
|
|
|
|
public func fetchCurrentInstance() async {
|
|
guard let client = client else { return }
|
|
instance = try? await client.get(endpoint: Instances.instance)
|
|
}
|
|
}
|