Kotlin style

This commit is contained in:
Benoit Marty 2019-07-16 15:59:08 +02:00
parent 0f7a56d005
commit 45f7d3e9c4

View file

@ -50,16 +50,10 @@ internal class SessionManager @Inject constructor(private val matrixComponent: M
}
private fun getOrCreateSessionComponent(sessionParams: SessionParams): SessionComponent {
val userId = sessionParams.credentials.userId
if (sessionComponents.containsKey(userId)) {
return sessionComponents[userId]!!
return sessionComponents.getOrPut(sessionParams.credentials.userId) {
DaggerSessionComponent
.factory()
.create(matrixComponent, sessionParams)
}
return DaggerSessionComponent
.factory()
.create(matrixComponent, sessionParams)
.also {
sessionComponents[userId] = it
}
}
}