Files
openclaw/apps/ios/Sources/Status/GatewayStatusBuilder.swift
Peter Steinberger 3261667b73 fix(ios): keep reconnect errors visible (#105875)
* fix(ios): keep reconnect errors visible

* fix(ios): clear stale errors on gateway switch

* chore(ios): keep release notes in PR

* fix(ios): reset status when switching gateways

* fix(ios): retain errors through same-target reconnect

* fix(ios): unpause explicit pairing retries

* fix(ios): isolate retained reconnect errors

* chore(i18n): resync rebased native inventory

* fix(ios): separate reconnect display state
2026-07-13 02:11:26 -07:00

42 lines
1.1 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 lastGatewayProblem != nil { 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
}
}