Only offer to verify if a cross-signed device is available and improve the UX whilst waiting. (#4710)

* Only offer to verify if a cross-signed device is available

* Wait until we know which verification options are available before showing them.

---------

Co-authored-by: Hubert Chathi <hubertc@matrix.org>
This commit is contained in:
Doug
2025-11-07 12:10:12 +00:00
committed by GitHub
parent 096e2d1713
commit 51a9d8b56b
15 changed files with 142 additions and 25 deletions
@@ -67,6 +67,7 @@ extension ClientProxyMock {
notificationSettings = configuration.notificationSettings
isOnlyDeviceLeftReturnValue = .success(false)
hasDevicesToVerifyAgainstReturnValue = .success(true)
accountURLActionReturnValue = "https://matrix.org/account"
canDeactivateAccount = false
directRoomForUserIDReturnValue = .failure(.sdkError(ClientProxyMockError.generic))
@@ -2287,6 +2287,70 @@ class ClientProxyMock: ClientProxyProtocol, @unchecked Sendable {
return isOnlyDeviceLeftReturnValue
}
}
//MARK: - hasDevicesToVerifyAgainst
var hasDevicesToVerifyAgainstUnderlyingCallsCount = 0
var hasDevicesToVerifyAgainstCallsCount: Int {
get {
if Thread.isMainThread {
return hasDevicesToVerifyAgainstUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = hasDevicesToVerifyAgainstUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
hasDevicesToVerifyAgainstUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
hasDevicesToVerifyAgainstUnderlyingCallsCount = newValue
}
}
}
}
var hasDevicesToVerifyAgainstCalled: Bool {
return hasDevicesToVerifyAgainstCallsCount > 0
}
var hasDevicesToVerifyAgainstUnderlyingReturnValue: Result<Bool, ClientProxyError>!
var hasDevicesToVerifyAgainstReturnValue: Result<Bool, ClientProxyError>! {
get {
if Thread.isMainThread {
return hasDevicesToVerifyAgainstUnderlyingReturnValue
} else {
var returnValue: Result<Bool, ClientProxyError>? = nil
DispatchQueue.main.sync {
returnValue = hasDevicesToVerifyAgainstUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
hasDevicesToVerifyAgainstUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
hasDevicesToVerifyAgainstUnderlyingReturnValue = newValue
}
}
}
}
var hasDevicesToVerifyAgainstClosure: (() async -> Result<Bool, ClientProxyError>)?
func hasDevicesToVerifyAgainst() async -> Result<Bool, ClientProxyError> {
hasDevicesToVerifyAgainstCallsCount += 1
if let hasDevicesToVerifyAgainstClosure = hasDevicesToVerifyAgainstClosure {
return await hasDevicesToVerifyAgainstClosure()
} else {
return hasDevicesToVerifyAgainstReturnValue
}
}
//MARK: - startSync
var startSyncUnderlyingCallsCount = 0