fix: migrate stale UserDefaults WebSocket URL on launch

UserDefaults persists across app reinstalls. Any device that
previously stored ws://100.64.0.2:9090 would ignore the new
defaultOrinURL constant. On init, if the saved URL contains
'100.64.0.2' it is cleared so the new default wss://www.saultee.bot/ws
is used on next launch.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sl-ios 2026-04-06 16:44:43 -04:00
parent efeff9e6c0
commit 313e84a516

View File

@ -132,6 +132,11 @@ final class SensorManager: NSObject, ObservableObject {
// MARK: - Init
override init() {
// Migrate: if the stored URL is the old Tailscale IP, replace with the new WSS endpoint.
if let saved = UserDefaults.standard.string(forKey: Self.orinURLKey),
saved.contains("100.64.0.2") {
UserDefaults.standard.removeObject(forKey: Self.orinURLKey)
}
let urlStr = UserDefaults.standard.string(forKey: Self.orinURLKey) ?? Self.defaultOrinURL
self.ws = WebSocketClient(url: URL(string: urlStr) ?? URL(string: Self.defaultOrinURL)!)
super.init()