Merge pull request #3425 from vector-im/feature/fga/fix_crash_signout

Fix crash on signout
This commit is contained in:
Benoit Marty 2021-05-28 15:44:02 +02:00 committed by GitHub
commit 270a195478
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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