Changes
2 changed files (+29/-0)
-
-
@@ -88,6 +88,16 @@ self.token = cancelling.tokenself.state = .failed(CancelError.cancelled) } #if DEBUG /// To prevent I/O in Xcode Preview environment. init(failingWith: CancelError) { self.serverID = "" self.host = "" self.port = 0 self.state = .failed(failingWith) } #endif init( serverID: String, host: String,
-
-
-
@@ -51,6 +51,25 @@ @State private var model: ConnectionDataModelWrapper =ConnectionDataModelWrapper(Self.storedConnection()) private static func storedConnection() -> ConnectionDataModel? { // Xcode Previews feature compiles and *runs* whole application. // Because Plac saves and restores from UserDefaults, the background instance // connects to Roon Server using the saved ID/host/port/token. The worst // part is running the app does not immediately terminate the background // instance--so there will be two app connecting to same destination using // same token. Roon Server drops the first connection, then the background // instance retries, then running instance dropped, then running instance // retries, so on... This results in endless connection loop. // // Below "guard" prevents that shitty "feature" from kicking in. An additional // bonus is, Preview loading performance is much better with this guard. #if DEBUG if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" { return ConnectionDataModel(failingWith: .cancelled) } #endif let port = UserDefaults.standard.integer(forKey: StorageKeys.serverPort) guard
-