fix:feature-parity
This commit is contained in:
1 parent
6c0a6eb498
commit
c33d87b06e
8 files changed
+196
-33
No files matched your search
@@ -18,8 +18,11 @@ enum TranscriptDestination: String, CaseIterable, Identifiable {
|
||||
@MainActor
|
||||
final class AppSettings: ObservableObject {
|
||||
private enum Key {
|
||||
static let endpoint = "endpoint"
|
||||
static let model = "model"
|
||||
static let hostedEndpoint = "endpoint"
|
||||
static let hostedModel = "model"
|
||||
static let localEndpoint = "local_endpoint"
|
||||
static let localModel = "local_model"
|
||||
static let hostedFirst = "hosted_first"
|
||||
static let prompt = "prompt"
|
||||
static let destination = "destination"
|
||||
static let shortcut = "shortcut"
|
||||
@@ -27,8 +30,21 @@ final class AppSettings: ObservableObject {
|
||||
|
||||
private let defaults: UserDefaults
|
||||
|
||||
@Published var endpoint: String { didSet { defaults.set(endpoint, forKey: Key.endpoint) } }
|
||||
@Published var model: String { didSet { defaults.set(model, forKey: Key.model) } }
|
||||
@Published var hostedEndpoint: String {
|
||||
didSet { defaults.set(hostedEndpoint, forKey: Key.hostedEndpoint) }
|
||||
}
|
||||
@Published var hostedModel: String {
|
||||
didSet { defaults.set(hostedModel, forKey: Key.hostedModel) }
|
||||
}
|
||||
@Published var localEndpoint: String {
|
||||
didSet { defaults.set(localEndpoint, forKey: Key.localEndpoint) }
|
||||
}
|
||||
@Published var localModel: String {
|
||||
didSet { defaults.set(localModel, forKey: Key.localModel) }
|
||||
}
|
||||
@Published var hostedFirst: Bool {
|
||||
didSet { defaults.set(hostedFirst, forKey: Key.hostedFirst) }
|
||||
}
|
||||
@Published var prompt: String { didSet { defaults.set(prompt, forKey: Key.prompt) } }
|
||||
@Published var destination: TranscriptDestination {
|
||||
didSet { defaults.set(destination.rawValue, forKey: Key.destination) }
|
||||
@@ -43,8 +59,11 @@ final class AppSettings: ObservableObject {
|
||||
|
||||
init(defaults: UserDefaults = .standard) {
|
||||
self.defaults = defaults
|
||||
endpoint = defaults.string(forKey: Key.endpoint) ?? ""
|
||||
model = defaults.string(forKey: Key.model) ?? ""
|
||||
hostedEndpoint = defaults.string(forKey: Key.hostedEndpoint) ?? ""
|
||||
hostedModel = defaults.string(forKey: Key.hostedModel) ?? ""
|
||||
localEndpoint = defaults.string(forKey: Key.localEndpoint) ?? "http://localhost:8080"
|
||||
localModel = defaults.string(forKey: Key.localModel) ?? ""
|
||||
hostedFirst = defaults.object(forKey: Key.hostedFirst) as? Bool ?? true
|
||||
prompt = defaults.string(forKey: Key.prompt) ?? ""
|
||||
destination =
|
||||
TranscriptDestination(
|
||||
@@ -59,8 +78,13 @@ final class AppSettings: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
var apiKey: String {
|
||||
get { KeychainStore.read() }
|
||||
set { KeychainStore.write(newValue) }
|
||||
var hostedKey: String {
|
||||
get { KeychainStore.read(.hosted) }
|
||||
set { KeychainStore.write(newValue, account: .hosted) }
|
||||
}
|
||||
|
||||
var localKey: String {
|
||||
get { KeychainStore.read(.local) }
|
||||
set { KeychainStore.write(newValue, account: .local) }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user