From 605a4172f1809accb0272935901d068876771f44 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Mon, 29 May 2023 13:15:46 +0200 Subject: [PATCH 1/4] Handle offline issue in UserSessionsDataProvider --- .../MatrixSDK/UserSessionsDataProvider.swift | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsDataProvider.swift b/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsDataProvider.swift index d54d865ac3..c154e4b825 100644 --- a/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsDataProvider.swift +++ b/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsDataProvider.swift @@ -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 } From 6a58218791afbce9bfac680c71509308e2c31023 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Mon, 29 May 2023 15:19:55 +0200 Subject: [PATCH 2/4] Fix initial state --- .../Service/MatrixSDK/UserSessionsOverviewService.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsOverviewService.swift b/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsOverviewService.swift index 9869ecd1ba..57851bb8bf 100644 --- a/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsOverviewService.swift +++ b/RiotSwiftUI/Modules/UserSessions/UserSessionsOverview/Service/MatrixSDK/UserSessionsOverviewService.swift @@ -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)) From d184b58d146a7313a262e1a498d7ccef404d86ce Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Mon, 29 May 2023 15:23:02 +0200 Subject: [PATCH 3/4] Add changelog.d file --- changelog.d/pr-7562.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/pr-7562.bugfix diff --git a/changelog.d/pr-7562.bugfix b/changelog.d/pr-7562.bugfix new file mode 100644 index 0000000000..825d074f32 --- /dev/null +++ b/changelog.d/pr-7562.bugfix @@ -0,0 +1 @@ +Device manager: fix offline state for user's sessions overview. \ No newline at end of file From 21670e4ee9a9ebf79f234ce01c330f5361d27ad3 Mon Sep 17 00:00:00 2001 From: Alfonso Grillo Date: Mon, 29 May 2023 16:48:46 +0200 Subject: [PATCH 4/4] Fix UTs --- RiotTests/UserSessionsDataProviderTests.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RiotTests/UserSessionsDataProviderTests.swift b/RiotTests/UserSessionsDataProviderTests.swift index 69b1b02295..7d5d9f59c9 100644 --- a/RiotTests/UserSessionsDataProviderTests.swift +++ b/RiotTests/UserSessionsDataProviderTests.swift @@ -209,6 +209,9 @@ private class MockCrossSigning: MXLegacyCrossSigning { super.init() } + override var state: MXCrossSigningState { + .crossSigningExists + } } /// A mock `MXDeviceInfo` that can override the `isVerified` state.