This commit is contained in:
snowspeeder committed 2026-08-31 19:50:46 -04:00
1 parent c9c25f86eb
commit 40aaf4fea7
56 files changed
+5683 -179

No files matched your search

+15 -1
View File
@@ -26,9 +26,23 @@ final class SettingsStore: ObservableObject {
static let volume = "volume"
}
static let defaultServerURL = "https://192.168.86.2:9178"
init() {
let d = UserDefaults.standard
serverURL = d.string(forKey: Keys.serverURL) ?? "https://192.168.86.2:9178"
// Sanitize legacy values: earlier versions wrote the field to storage on
// every keystroke, so an invalid half-typed URL could be persisted and
// shipped to the network layer. Fall back to the documented default and
// repair the stored value once.
let storedURL = d.string(forKey: Keys.serverURL) ?? Self.defaultServerURL
switch ServerConfig.parse(storedURL) {
case .success:
serverURL = storedURL
case .failure:
// Legacy invalid value: repair to the documented default.
serverURL = Self.defaultServerURL
d.set(Self.defaultServerURL, forKey: Keys.serverURL)
}
let storedVoice = d.string(forKey: Keys.voiceID)
voiceID = Voices.all.contains { $0.id == storedVoice } ? (storedVoice ?? "") : Voices.defaultID
modelID = d.string(forKey: Keys.modelID)