Skip to content

Commit

Permalink
Add VerificationState.isUnverified
Browse files Browse the repository at this point in the history
  • Loading branch information
alfogrillo committed Nov 18, 2022
1 parent f0f775c commit 6b01a72
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions RiotSwiftUI/Modules/UserSessions/Common/UserSessionInfo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ struct UserSessionInfo: Identifiable {
case verified
/// A session which cannot be never verified due to lack of crypto support
case permanentlyUnverified

var isUnverified: Bool {
self == .unverified || self == .permanentlyUnverified
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class UserOtherSessionsViewModelTests: XCTestCase {

let expectedItems = sessionInfos
.filter {
!$0.isCurrent && ($0.verificationState == .unverified || $0.verificationState == .permanentlyUnverified)
!$0.isCurrent && $0.verificationState.isUnverified
}
.asViewData()
let bindings = UserOtherSessionsBindings(filter: .unverified, isEditModeEnabled: false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ private extension UserOtherSessionsFilter {
case .inactive:
return sessionInfos.filter { !$0.isActive }
case .unverified:
return sessionInfos.filter { $0.verificationState == .unverified || $0.verificationState == .permanentlyUnverified }
return sessionInfos.filter { $0.verificationState.isUnverified }
case .verified:
return sessionInfos.filter { $0.verificationState == .verified }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ class UserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
private func sessionsOverviewData(from allSessions: [UserSessionInfo],
linkDeviceEnabled: Bool) -> UserSessionsOverviewData {
UserSessionsOverviewData(currentSession: allSessions.filter(\.isCurrent).first,
unverifiedSessions: allSessions.filter { ($0.verificationState == .unverified || $0.verificationState == .permanentlyUnverified) && !$0.isCurrent },
unverifiedSessions: allSessions.filter { $0.verificationState.isUnverified && !$0.isCurrent },
inactiveSessions: allSessions.filter { !$0.isActive },
otherSessions: allSessions.filter { !$0.isCurrent },
linkDeviceEnabled: linkDeviceEnabled)
Expand Down

0 comments on commit 6b01a72

Please sign in to comment.