Files
openclaw/apps/ios/Sources/Status/GatewayStatusBuilder.swift
Peter Steinberger 091584b197 chore(swift): restore compact conditional bodies (#103832)
* style(swift): restore compact conditional bodies

* fix(ios): remove redundant startup timeout await

* chore(swift): sync native i18n inventory
2026-07-10 18:12:00 +01:00

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
}
}