mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 18:35:40 +03:00
Small cleanup
This commit is contained in:
parent
6d8b5db18e
commit
96d5652fcd
2 changed files with 5 additions and 6 deletions
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue