element-ios/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/UserSessionsOverviewService...

31 lines
1.0 KiB
Swift

//
// Copyright 2022-2024 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only
// Please see LICENSE in the repository root for full details.
//
import Combine
struct UserSessionsOverviewData {
let currentSession: UserSessionInfo?
let unverifiedSessions: [UserSessionInfo]
let inactiveSessions: [UserSessionInfo]
let otherSessions: [UserSessionInfo]
let linkDeviceEnabled: Bool
}
protocol UserSessionsOverviewServiceProtocol {
var overviewDataPublisher: CurrentValueSubject<UserSessionsOverviewData, Never> { get }
func updateOverviewData(completion: @escaping (Result<UserSessionsOverviewData, Error>) -> Void) -> Void
func sessionForIdentifier(_ sessionId: String) -> UserSessionInfo?
}
extension UserSessionsOverviewServiceProtocol {
/// The user's current session.
var currentSession: UserSessionInfo? { overviewDataPublisher.value.currentSession }
/// Any sessions that are verified and have been seen recently.
var otherSessions: [UserSessionInfo] { overviewDataPublisher.value.otherSessions }
}