Skip to content

Commit

Permalink
Merge pull request #7562 from vector-im/alfogrillo/dm_no_internet_status
Browse files Browse the repository at this point in the history
Fix offline state issue in user sessions overview
  • Loading branch information
Alfonso Grillo authored May 30, 2023
2 parents 223d150 + 21670e4 commit 2bd099e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,17 @@ class UserSessionsDataProvider: UserSessionsDataProviderProtocol {
guard let deviceInfo = deviceInfo else {
return .permanentlyUnverified
}

guard session.crypto?.crossSigning.canCrossSign == true else {

// When the app is launched offline the cross signing state is "notBootstrapped"
// In this edge case the verification state returned is `.unknown` since we cannot say more even for the current session.
guard
let crossSigning = session.crypto?.crossSigning,
crossSigning.state.rawValue > MXCrossSigningState.notBootstrapped.rawValue
else {
return .unknown
}

guard crossSigning.canCrossSign else {
return deviceInfo.deviceId == session.myDeviceId ? .unverified : .unknown
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ class UserSessionsOverviewService: UserSessionsOverviewServiceProtocol {
}

overviewDataPublisher = .init(UserSessionsOverviewData(currentSession: currentSessionInfo,
unverifiedSessions: currentSessionInfo.verificationState == .verified ? [] : [currentSessionInfo],
unverifiedSessions: currentSessionInfo.verificationState.isUnverified ? [currentSessionInfo] : [],
inactiveSessions: currentSessionInfo.isActive ? [] : [currentSessionInfo],
otherSessions: [],
linkDeviceEnabled: false))
Expand Down
3 changes: 3 additions & 0 deletions RiotTests/UserSessionsDataProviderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ private class MockCrossSigning: MXLegacyCrossSigning {
super.init()
}

override var state: MXCrossSigningState {
.crossSigningExists
}
}

/// A mock `MXDeviceInfo` that can override the `isVerified` state.
Expand Down
1 change: 1 addition & 0 deletions changelog.d/pr-7562.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Device manager: fix offline state for user's sessions overview.

0 comments on commit 2bd099e

Please sign in to comment.