Secure backup tweaks (#2277)

* Use a custom SDK build that might fix incomplete recovery state false positives. Enable chat backup by default

* Get rid of the chat backup feature flag

* Fix force unwrap warning

* Fix long line warning

* Prevent the recovery key confirmation banner popping up before the verification state is fetched. Stop showing secure backup user avatar and menu badges while the session is not verified.

* Switch back to the release version of the SDK

* Fix inconsistent session verification states, improve/simplify how to deal with it

* Fix unit tests

* Cleanup and hopefully simplify home screen banner presentations
This commit is contained in:
Stefan Ceriu
2023-12-21 17:08:29 +02:00
committed by GitHub
parent d148827eae
commit 0ae71f740d
18 changed files with 67 additions and 82 deletions
@@ -25,4 +25,5 @@ struct MockUserSession: UserSessionProtocol {
let clientProxy: ClientProxyProtocol
let mediaProvider: MediaProviderProtocol
let voiceMessageMediaManager: VoiceMessageMediaManagerProtocol
var sessionVerificationState: CurrentValuePublisher<Bool?, Never> = .init(.init(true))
}
@@ -29,9 +29,16 @@ class UserSession: UserSessionProtocol {
let clientProxy: ClientProxyProtocol
let mediaProvider: MediaProviderProtocol
let voiceMessageMediaManager: VoiceMessageMediaManagerProtocol
let callbacks = PassthroughSubject<UserSessionCallback, Never>()
private(set) var sessionVerificationController: SessionVerificationControllerProxyProtocol?
private var sessionVerificationStateSubject: CurrentValueSubject<Bool?, Never> = .init(nil)
var sessionVerificationState: CurrentValuePublisher<Bool?, Never> {
sessionVerificationStateSubject.asCurrentValuePublisher()
}
init(clientProxy: ClientProxyProtocol, mediaProvider: MediaProviderProtocol, voiceMessageMediaManager: VoiceMessageMediaManagerProtocol) {
self.clientProxy = clientProxy
self.mediaProvider = mediaProvider
@@ -64,16 +71,14 @@ class UserSession: UserSessionProtocol {
tearDownSessionVerificationControllerWatchdog()
if !isVerified {
callbacks.send(.sessionVerificationNeeded)
}
self.sessionVerificationController = sessionVerificationController
sessionVerificationStateSubject.send(isVerified)
sessionVerificationController.callbacks.sink { [weak self] callback in
switch callback {
case .finished:
self?.callbacks.send(.didVerifySession)
self?.sessionVerificationStateSubject.send(true)
default:
break
}
@@ -18,8 +18,6 @@ import Combine
import Foundation
enum UserSessionCallback {
case sessionVerificationNeeded
case didVerifySession
case didReceiveAuthError(isSoftLogout: Bool)
}
@@ -32,6 +30,7 @@ protocol UserSessionProtocol {
var mediaProvider: MediaProviderProtocol { get }
var voiceMessageMediaManager: VoiceMessageMediaManagerProtocol { get }
var sessionVerificationState: CurrentValuePublisher<Bool?, Never> { get }
var sessionVerificationController: SessionVerificationControllerProxyProtocol? { get }
var callbacks: PassthroughSubject<UserSessionCallback, Never> { get }