Fix crash on signout

This commit is contained in:
ganfra 2021-05-28 10:29:21 +02:00
parent d2fd652fb5
commit cc6263b20f
2 changed files with 6 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import org.matrix.android.sdk.api.extensions.tryOrNull
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.internal.SessionManager
import org.matrix.android.sdk.internal.di.SessionId
import timber.log.Timber
import javax.inject.Inject
@SessionScope
@ -43,15 +44,16 @@ internal class SessionListeners @Inject constructor(
fun dispatch(block: (Session, Session.Listener) -> Unit) {
synchronized(listeners) {
val session = getSession()
val session = getSession() ?: return Unit.also {
Timber.w("You don't have any attached session")
}
listeners.forEach {
tryOrNull { block(session, it) }
}
}
}
private fun getSession(): Session {
private fun getSession(): Session? {
return sessionManager.getSessionComponent(sessionId)?.session()
?: throw IllegalStateException("No session found with this id.")
}
}

1
newsfragment/3424.bugfix Normal file
View File

@ -0,0 +1 @@
Fix app crashing when signing out