Small cleanup

This commit is contained in:
Benoit Marty 2021-12-31 15:48:08 +01:00
parent 6d8b5db18e
commit 96d5652fcd
2 changed files with 5 additions and 6 deletions

View file

@ -29,12 +29,12 @@ import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.onEach
import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.accountdata.UserAccountDataTypes
import org.matrix.android.sdk.api.session.events.model.toModel
import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.flow.unwrap
import timber.log.Timber
data class DummyState(
@ -60,8 +60,8 @@ class UserColorAccountDataViewModel @AssistedInject constructor(
private fun observeAccountData() {
session.flow()
.liveUserAccountData(setOf(UserAccountDataTypes.TYPE_OVERRIDE_COLORS))
.mapNotNull { it.firstOrNull() }
.liveUserAccountData(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
.unwrap()
.map { it.content.toModel<Map<String, String>>() }
.onEach { userColorAccountDataContent ->
if (userColorAccountDataContent == null) {

View file

@ -39,7 +39,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.mapNotNull
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
@ -131,8 +130,8 @@ class RoomMemberProfileViewModel @AssistedInject constructor(
private fun observeAccountData() {
session.flow()
.liveUserAccountData(setOf(UserAccountDataTypes.TYPE_OVERRIDE_COLORS))
.mapNotNull { it.firstOrNull() }
.liveUserAccountData(UserAccountDataTypes.TYPE_OVERRIDE_COLORS)
.unwrap()
.map { it.content.toModel<Map<String, String>>() }
.map { userColorAccountDataContent ->
userColorAccountDataContent?.get(initialState.userId)