mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-15 11:56:01 +00:00
* style(swift): restore compact conditional bodies * fix(ios): remove redundant startup timeout await * chore(swift): sync native i18n inventory
42 lines
1.2 KiB
Swift
42 lines
1.2 KiB
Swift
import Foundation
|
|
import OpenClawKit
|
|
|
|
enum GatewayDisplayState: Equatable {
|
|
case connected
|
|
case connecting
|
|
case error
|
|
case disconnected
|
|
}
|
|
|
|
enum GatewayStatusBuilder {
|
|
@MainActor
|
|
static func build(appModel: NodeAppModel) -> GatewayDisplayState {
|
|
self.build(
|
|
gatewayServerName: appModel.gatewayServerName,
|
|
lastGatewayProblem: appModel.lastGatewayProblem,
|
|
gatewayStatusText: appModel.gatewayStatusText)
|
|
}
|
|
|
|
static func build(
|
|
gatewayServerName: String?,
|
|
lastGatewayProblem: GatewayConnectionProblem?,
|
|
gatewayStatusText: String) -> GatewayDisplayState
|
|
{
|
|
if gatewayServerName != nil { return .connected }
|
|
if let lastGatewayProblem, lastGatewayProblem.pauseReconnect { return .error }
|
|
|
|
let text = gatewayStatusText.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
if text.localizedCaseInsensitiveContains("connecting") ||
|
|
text.localizedCaseInsensitiveContains("reconnecting")
|
|
{
|
|
return .connecting
|
|
}
|
|
|
|
if text.localizedCaseInsensitiveContains("error") {
|
|
return .error
|
|
}
|
|
|
|
return .disconnected
|
|
}
|
|
}
|