mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Soft logout removal (#672)
* Remove isSoftLogout from everywhere except the client delegate - bump the RustSDK to v1.0.43 - cleanup the app coordinator state machine and login/logout flows * Merge `succeededSigningIn` and `succeededRestoringSession` into `createdUserSession` in order to simplify the logic
This commit is contained in:
@@ -35,11 +35,6 @@ private class WeakClientProxyWrapper: ClientDelegate, SlidingSyncObserver {
|
||||
clientProxy?.didReceiveAuthError(isSoftLogout: isSoftLogout)
|
||||
}
|
||||
|
||||
func didUpdateRestoreToken() {
|
||||
MXLog.info("Did update restoration token")
|
||||
clientProxy?.didUpdateRestoreToken()
|
||||
}
|
||||
|
||||
// MARK: - SlidingSyncDelegate
|
||||
|
||||
func didReceiveSyncUpdate(summary: UpdateSummary) {
|
||||
@@ -98,10 +93,6 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
var isSoftLogout: Bool {
|
||||
client.isSoftLogout()
|
||||
}
|
||||
|
||||
var deviceId: String? {
|
||||
do {
|
||||
return try client.deviceId()
|
||||
@@ -126,7 +117,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
|
||||
func startSync() {
|
||||
MXLog.info("Starting sync")
|
||||
guard !client.isSoftLogout(), slidingSyncObserverToken == nil else {
|
||||
guard slidingSyncObserverToken == nil else {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -382,10 +373,6 @@ class ClientProxy: ClientProxyProtocol {
|
||||
fileprivate func didReceiveAuthError(isSoftLogout: Bool) {
|
||||
callbacks.send(.receivedAuthError(isSoftLogout: isSoftLogout))
|
||||
}
|
||||
|
||||
fileprivate func didUpdateRestoreToken() {
|
||||
callbacks.send(.updatedRestoreToken)
|
||||
}
|
||||
|
||||
fileprivate func didReceiveSlidingSyncUpdate(summary: UpdateSummary) {
|
||||
callbacks.send(.receivedSyncUpdate)
|
||||
|
||||
@@ -21,7 +21,6 @@ import MatrixRustSDK
|
||||
enum ClientProxyCallback {
|
||||
case receivedSyncUpdate
|
||||
case receivedAuthError(isSoftLogout: Bool)
|
||||
case updatedRestoreToken
|
||||
}
|
||||
|
||||
enum ClientProxyError: Error {
|
||||
@@ -69,8 +68,6 @@ protocol ClientProxyProtocol: AnyObject, MediaLoaderProtocol {
|
||||
|
||||
var userID: String { get }
|
||||
|
||||
var isSoftLogout: Bool { get }
|
||||
|
||||
var deviceId: String? { get }
|
||||
|
||||
var homeserver: String { get }
|
||||
|
||||
@@ -22,7 +22,6 @@ class MockClientProxy: ClientProxyProtocol {
|
||||
let callbacks = PassthroughSubject<ClientProxyCallback, Never>()
|
||||
|
||||
let userID: String
|
||||
let isSoftLogout = false
|
||||
let deviceId: String? = nil
|
||||
let homeserver = ""
|
||||
let restorationToken: RestorationToken? = nil
|
||||
|
||||
@@ -20,7 +20,6 @@ struct MockUserSession: UserSessionProtocol {
|
||||
let callbacks = PassthroughSubject<UserSessionCallback, Never>()
|
||||
let sessionVerificationController: SessionVerificationControllerProxyProtocol? = nil
|
||||
var userID: String { clientProxy.userID }
|
||||
var isSoftLogout: Bool { clientProxy.isSoftLogout }
|
||||
var deviceID: String? { clientProxy.deviceId }
|
||||
var homeserver: String { clientProxy.homeserver }
|
||||
let clientProxy: ClientProxyProtocol
|
||||
|
||||
@@ -21,10 +21,8 @@ class UserSession: UserSessionProtocol {
|
||||
private var cancellables = Set<AnyCancellable>()
|
||||
private var checkForSessionVerificationControllerCancellable: AnyCancellable?
|
||||
private var authErrorCancellable: AnyCancellable?
|
||||
private var restoreTokenUpdateCancellable: AnyCancellable?
|
||||
|
||||
var userID: String { clientProxy.userID }
|
||||
var isSoftLogout: Bool { clientProxy.isSoftLogout }
|
||||
var deviceID: String? { clientProxy.deviceId }
|
||||
var homeserver: String { clientProxy.homeserver }
|
||||
|
||||
@@ -39,7 +37,6 @@ class UserSession: UserSessionProtocol {
|
||||
|
||||
setupSessionVerificationWatchdog()
|
||||
setupAuthErrorWatchdog()
|
||||
setupRestoreTokenUpdateWatchdog()
|
||||
}
|
||||
|
||||
// MARK: - Private
|
||||
@@ -102,21 +99,4 @@ class UserSession: UserSessionProtocol {
|
||||
private func tearDownAuthErrorWatchdog() {
|
||||
authErrorCancellable = nil
|
||||
}
|
||||
|
||||
// MARK: Restore Token Update Watchdog
|
||||
|
||||
private func setupRestoreTokenUpdateWatchdog() {
|
||||
restoreTokenUpdateCancellable = clientProxy.callbacks
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] callback in
|
||||
if case .updatedRestoreToken = callback {
|
||||
self?.callbacks.send(.updateRestoreTokenNeeded)
|
||||
self?.tearDownRestoreTokenUpdateWatchdog()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func tearDownRestoreTokenUpdateWatchdog() {
|
||||
restoreTokenUpdateCancellable = nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ enum UserSessionCallback {
|
||||
case sessionVerificationNeeded
|
||||
case didVerifySession
|
||||
case didReceiveAuthError(isSoftLogout: Bool)
|
||||
case updateRestoreTokenNeeded
|
||||
}
|
||||
|
||||
protocol UserSessionProtocol {
|
||||
@@ -29,8 +28,6 @@ protocol UserSessionProtocol {
|
||||
var userID: String { get }
|
||||
var deviceID: String? { get }
|
||||
|
||||
var isSoftLogout: Bool { get }
|
||||
|
||||
var clientProxy: ClientProxyProtocol { get }
|
||||
var mediaProvider: MediaProviderProtocol { get }
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@ extension MatrixRustSDK.Session: Codable {
|
||||
userId: try container.decode(String.self, forKey: .userId),
|
||||
deviceId: try container.decode(String.self, forKey: .deviceId),
|
||||
homeserverUrl: try container.decode(String.self, forKey: .homeserverUrl),
|
||||
isSoftLogout: try container.decode(Bool.self, forKey: .isSoftLogout),
|
||||
slidingSyncProxy: try container.decode(String.self, forKey: .slidingSyncProxy))
|
||||
}
|
||||
|
||||
@@ -40,11 +39,10 @@ extension MatrixRustSDK.Session: Codable {
|
||||
try container.encode(userId, forKey: .userId)
|
||||
try container.encode(deviceId, forKey: .deviceId)
|
||||
try container.encode(homeserverUrl, forKey: .homeserverUrl)
|
||||
try container.encode(isSoftLogout, forKey: .isSoftLogout)
|
||||
try container.encode(slidingSyncProxy, forKey: .slidingSyncProxy)
|
||||
}
|
||||
|
||||
enum CodingKeys: String, CodingKey {
|
||||
case accessToken, refreshToken, userId, deviceId, homeserverUrl, isSoftLogout, slidingSyncProxy
|
||||
case accessToken, refreshToken, userId, deviceId, homeserverUrl, slidingSyncProxy
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user