conversations-classic-ios/old/AppCore/Models/ConnectionStatus.swift

28 lines
732 B
Swift
Raw Normal View History

2024-06-19 15:15:27 +00:00
// 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)
}
}
}