Try to centralise session restoration through MatrixClientsHolder

This commit is contained in:
Jorge Martín 2023-07-17 15:05:13 +02:00
parent d69dea6608
commit ded1518f0b
5 changed files with 36 additions and 21 deletions

View file

@ -145,14 +145,10 @@ class RootFlowNode @AssistedInject constructor(
onFailure: () -> Unit = {},
onSuccess: (SessionId) -> Unit = {},
) {
// If the session is already known it'll be restored by the node hierarchy
if (matrixClientsHolder.knowSession(sessionId)) {
Timber.v("Session $sessionId already alive, no need to restore.")
return
runCatching {
matrixClientsHolder.requireSession(sessionId)
}
authenticationService.restoreSession(sessionId)
.onSuccess { matrixClient ->
matrixClientsHolder.add(matrixClient)
.onSuccess {
Timber.v("Succeed to restore session $sessionId")
onSuccess(sessionId)
}