refactor: apply stashed bridge + CLI changes
This commit is contained in:
@@ -77,17 +77,20 @@ struct SettingsTab: View {
|
||||
guard let existing, !existing.isEmpty else { return }
|
||||
guard let target = self.pickAutoConnectBridge(from: newValue) else { return }
|
||||
|
||||
self.didAutoConnect = true
|
||||
self.preferredBridgeStableID = target.stableID
|
||||
self.appModel.connectToBridge(
|
||||
endpoint: target.endpoint,
|
||||
token: existing,
|
||||
nodeId: self.instanceId,
|
||||
displayName: self.displayName,
|
||||
platform: self.platformString(),
|
||||
version: self.appVersion())
|
||||
self.connectStatus = nil
|
||||
}
|
||||
self.didAutoConnect = true
|
||||
self.preferredBridgeStableID = target.stableID
|
||||
self.appModel.connectToBridge(
|
||||
endpoint: target.endpoint,
|
||||
hello: BridgeHello(
|
||||
nodeId: self.instanceId,
|
||||
displayName: self.displayName,
|
||||
token: existing,
|
||||
platform: self.platformString(),
|
||||
version: self.appVersion()
|
||||
)
|
||||
)
|
||||
self.connectStatus = nil
|
||||
}
|
||||
.onChange(of: self.appModel.bridgeServerName) { _, _ in
|
||||
self.connectStatus = nil
|
||||
}
|
||||
@@ -170,18 +173,22 @@ struct SettingsTab: View {
|
||||
existing :
|
||||
nil
|
||||
|
||||
let token = try await BridgeClient().pairAndHello(
|
||||
endpoint: bridge.endpoint,
|
||||
nodeId: self.instanceId,
|
||||
displayName: self.displayName,
|
||||
platform: self.platformString(),
|
||||
version: self.appVersion(),
|
||||
existingToken: existingToken,
|
||||
onStatus: { status in
|
||||
Task { @MainActor in
|
||||
self.connectStatus = status
|
||||
}
|
||||
})
|
||||
let hello = BridgeHello(
|
||||
nodeId: self.instanceId,
|
||||
displayName: self.displayName,
|
||||
token: existingToken,
|
||||
platform: self.platformString(),
|
||||
version: self.appVersion()
|
||||
)
|
||||
let token = try await BridgeClient().pairAndHello(
|
||||
endpoint: bridge.endpoint,
|
||||
hello: hello,
|
||||
onStatus: { status in
|
||||
Task { @MainActor in
|
||||
self.connectStatus = status
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
if !token.isEmpty, token != existingToken {
|
||||
_ = KeychainStore.saveString(
|
||||
@@ -190,13 +197,16 @@ struct SettingsTab: View {
|
||||
account: self.keychainAccount())
|
||||
}
|
||||
|
||||
self.appModel.connectToBridge(
|
||||
endpoint: bridge.endpoint,
|
||||
token: token,
|
||||
nodeId: self.instanceId,
|
||||
displayName: self.displayName,
|
||||
platform: self.platformString(),
|
||||
version: self.appVersion())
|
||||
self.appModel.connectToBridge(
|
||||
endpoint: bridge.endpoint,
|
||||
hello: BridgeHello(
|
||||
nodeId: self.instanceId,
|
||||
displayName: self.displayName,
|
||||
token: token,
|
||||
platform: self.platformString(),
|
||||
version: self.appVersion()
|
||||
)
|
||||
)
|
||||
|
||||
} catch {
|
||||
self.connectStatus = "Failed: \(error.localizedDescription)"
|
||||
|
||||
Reference in New Issue
Block a user