another.im-ios/ConversationsClassic/AppCore/Models/ConnectionStatus.swift
2024-06-19 17:15:27 +02:00

28 lines
732 B
Swift

// This struct is simpliest variant of Martin's Client State.
// Just for more comfortable using in App State
import Foundation
import Martin
enum ConnectionStatus: Stateable {
case connecting
case connected(resumed: Bool = false)
case disconnecting
case disconnected(reason: String)
static func from(_ state: XMPPClient.State) -> ConnectionStatus {
switch state {
case .connecting:
return .connecting
case .connected(let resumed):
return .connected(resumed: resumed)
case .disconnecting:
return .disconnecting
case .disconnected(let reason):
return .disconnected(reason: reason.localizedDescription)
}
}
}