Make sure to save the tokens the Client might return when its session is restored (#3378)

* Use `ClientSessionDelegate` to ensure tokens are always updated.

Refreshed tokens on client restoration might not have been stored to disk if the token refresh happened before `RustMatrixClient` was built and the `ClientDelegate` was set in it.

Using `ClientSessionDelegate` should ensure the tokens refreshed callback is called at any point in time.

* Improve how assigning the Client works, fix docs

* Fix review comments
This commit is contained in:
Jorge Martin Espinosa 2024-09-04 10:54:31 +02:00 committed by GitHub
parent 9fb82a1e86
commit 2c8b0d0b95
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 161 additions and 98 deletions

View file

@ -122,7 +122,7 @@ class FakeMatrixClient(
var getRoomInfoFlowLambda = { _: RoomId ->
flowOf<Optional<MatrixRoomInfo>>(Optional.empty())
}
var logoutLambda: (Boolean) -> String? = {
var logoutLambda: (Boolean, Boolean) -> String? = { _, _ ->
null
}
@ -170,8 +170,8 @@ class FakeMatrixClient(
clearCacheLambda()
}
override suspend fun logout(ignoreSdkError: Boolean): String? = simulateLongTask {
return logoutLambda(ignoreSdkError)
override suspend fun logout(userInitiated: Boolean, ignoreSdkError: Boolean): String? = simulateLongTask {
return logoutLambda(ignoreSdkError, userInitiated)
}
override fun close() = Unit