Mavericks 2: clean code, but have warnings

This commit is contained in:
ganfra 2021-10-08 16:45:29 +02:00
parent c66d6aab5c
commit 2a29243298
31 changed files with 35 additions and 66 deletions

View file

@ -80,7 +80,7 @@ allprojects {
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
// Warnings are potential errors, so stop ignoring them // Warnings are potential errors, so stop ignoring them
// You can override by passing `-PallWarningsAsErrors=false` in the command line // You can override by passing `-PallWarningsAsErrors=false` in the command line
kotlinOptions.allWarningsAsErrors = false //project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean() kotlinOptions.allWarningsAsErrors = project.getProperties().getOrDefault("allWarningsAsErrors", "true").toBoolean()
} }
// Fix "Java heap space" issue // Fix "Java heap space" issue

View file

@ -16,14 +16,12 @@
package org.matrix.android.sdk.flow package org.matrix.android.sdk.flow
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.*
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith
import org.junit.Assert.*
/** /**
* Instrumented test, which will execute on an Android device. * Instrumented test, which will execute on an Android device.
* *

View file

@ -36,8 +36,8 @@ class FlowRoom(private val room: Room) {
fun liveRoomSummary(): Flow<Optional<RoomSummary>> { fun liveRoomSummary(): Flow<Optional<RoomSummary>> {
return room.getRoomSummaryLive().asFlow() return room.getRoomSummaryLive().asFlow()
.startWith { .startWith {
room.roomSummary().toOptional() room.roomSummary().toOptional()
} }
} }

View file

@ -16,9 +16,8 @@
package org.matrix.android.sdk.flow package org.matrix.android.sdk.flow
import org.junit.Test
import org.junit.Assert.* import org.junit.Assert.*
import org.junit.Test
/** /**
* Example local unit test, which will execute on the development machine (host). * Example local unit test, which will execute on the development machine (host).

View file

@ -378,6 +378,7 @@ dependencies {
kapt libs.airbnb.epoxyProcessor kapt libs.airbnb.epoxyProcessor
implementation libs.airbnb.epoxyPaging implementation libs.airbnb.epoxyPaging
implementation libs.airbnb.mavericks implementation libs.airbnb.mavericks
//TODO: remove when entirely migrated to Flow
implementation libs.airbnb.mavericksRx implementation libs.airbnb.mavericksRx
// Work // Work

View file

@ -27,9 +27,8 @@ import android.widget.FrameLayout
import androidx.annotation.CallSuper import androidx.annotation.CallSuper
import androidx.lifecycle.ViewModelProvider import androidx.lifecycle.ViewModelProvider
import androidx.viewbinding.ViewBinding import androidx.viewbinding.ViewBinding
import com.airbnb.mvrx.MavericksView
import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.Mavericks
import com.airbnb.mvrx.MvRxView import com.airbnb.mvrx.MavericksView
import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetBehavior
import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.bottomsheet.BottomSheetDialog
import com.google.android.material.bottomsheet.BottomSheetDialogFragment import com.google.android.material.bottomsheet.BottomSheetDialogFragment

View file

@ -631,10 +631,11 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
const val INCOMING_ACCEPT = "INCOMING_ACCEPT" const val INCOMING_ACCEPT = "INCOMING_ACCEPT"
fun newIntent(context: Context, call: WebRtcCall, mode: String?): Intent { fun newIntent(context: Context, call: WebRtcCall, mode: String?): Intent {
val callArgs = CallArgs(call.nativeRoomId, call.callId, call.mxCall.opponentUserId, !call.mxCall.isOutgoing, call.mxCall.isVideoCall)
return Intent(context, VectorCallActivity::class.java).apply { return Intent(context, VectorCallActivity::class.java).apply {
// what could be the best flags? // what could be the best flags?
flags = Intent.FLAG_ACTIVITY_NEW_TASK flags = Intent.FLAG_ACTIVITY_NEW_TASK
putExtra(Mavericks.KEY_ARG, CallArgs(call.nativeRoomId, call.callId, call.mxCall.opponentUserId, !call.mxCall.isOutgoing, call.mxCall.isVideoCall)) putExtra(Mavericks.KEY_ARG, callArgs)
putExtra(EXTRA_MODE, mode) putExtra(EXTRA_MODE, mode)
} }
} }
@ -646,10 +647,11 @@ class VectorCallActivity : VectorBaseActivity<ActivityCallBinding>(), CallContro
isIncomingCall: Boolean, isIncomingCall: Boolean,
isVideoCall: Boolean, isVideoCall: Boolean,
mode: String?): Intent { mode: String?): Intent {
val callArgs = CallArgs(signalingRoomId, callId, otherUserId, isIncomingCall, isVideoCall)
return Intent(context, VectorCallActivity::class.java).apply { return Intent(context, VectorCallActivity::class.java).apply {
// what could be the best flags? // what could be the best flags?
flags = Intent.FLAG_ACTIVITY_NEW_TASK flags = Intent.FLAG_ACTIVITY_NEW_TASK
putExtra(Mavericks.KEY_ARG, CallArgs(signalingRoomId, callId, otherUserId, isIncomingCall, isVideoCall)) putExtra(Mavericks.KEY_ARG, callArgs)
putExtra(EXTRA_MODE, mode) putExtra(EXTRA_MODE, mode)
} }
} }

View file

@ -28,7 +28,6 @@ import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import io.reactivex.disposables.Disposable
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.distinctUntilChanged
@ -39,7 +38,6 @@ import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.widgets.model.Widget import org.matrix.android.sdk.api.session.widgets.model.Widget
import org.matrix.android.sdk.api.session.widgets.model.WidgetType import org.matrix.android.sdk.api.session.widgets.model.WidgetType
import org.matrix.android.sdk.rx.asObservable
class JitsiCallViewModel @AssistedInject constructor( class JitsiCallViewModel @AssistedInject constructor(
@Assisted initialState: JitsiCallViewState, @Assisted initialState: JitsiCallViewState,

View file

@ -26,21 +26,21 @@ import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject import dagger.assisted.AssistedInject
import im.vector.app.R
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import im.vector.app.R
import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.StringProvider
import im.vector.app.core.utils.ensureProtocol import im.vector.app.core.utils.ensureProtocol
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.identity.IdentityServiceError import org.matrix.android.sdk.api.session.identity.IdentityServiceError
import org.matrix.android.sdk.api.session.identity.IdentityServiceListener import org.matrix.android.sdk.api.session.identity.IdentityServiceListener
import org.matrix.android.sdk.api.session.identity.SharedState import org.matrix.android.sdk.api.session.identity.SharedState
import org.matrix.android.sdk.api.session.identity.ThreePid import org.matrix.android.sdk.api.session.identity.ThreePid
import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.api.session.terms.TermsService import org.matrix.android.sdk.api.session.terms.TermsService
import org.matrix.android.sdk.flow.flow
class DiscoverySettingsViewModel @AssistedInject constructor( class DiscoverySettingsViewModel @AssistedInject constructor(
@Assisted initialState: DiscoverySettingsState, @Assisted initialState: DiscoverySettingsState,

View file

@ -27,10 +27,10 @@ import android.view.MenuItem
import androidx.core.view.GravityCompat import androidx.core.view.GravityCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout
import androidx.lifecycle.lifecycleScope
import com.airbnb.mvrx.Mavericks
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import androidx.lifecycle.lifecycleScope
import com.airbnb.mvrx.Mavericks
import com.airbnb.mvrx.viewModel import com.airbnb.mvrx.viewModel
import com.google.android.material.appbar.MaterialToolbar import com.google.android.material.appbar.MaterialToolbar
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
@ -74,7 +74,6 @@ import im.vector.app.features.themes.ThemeUtils
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
import im.vector.app.features.workers.signout.ServerBackupStatusViewState import im.vector.app.features.workers.signout.ServerBackupStatusViewState
import im.vector.app.push.fcm.FcmHelper import im.vector.app.push.fcm.FcmHelper
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.session.initsync.SyncStatusService import org.matrix.android.sdk.api.session.initsync.SyncStatusService
@ -319,8 +318,8 @@ class HomeActivity :
buildTask = true buildTask = true
) )
if (!isHandled) { if (!isHandled) {
val isMatrixToLink = deepLink.startsWith(PermalinkService.MATRIX_TO_URL_BASE) val isMatrixToLink = deepLink.startsWith(PermalinkService.MATRIX_TO_URL_BASE) ||
|| deepLink.startsWith(MATRIX_TO_CUSTOM_SCHEME_URL_BASE) deepLink.startsWith(MATRIX_TO_CUSTOM_SCHEME_URL_BASE)
MaterialAlertDialogBuilder(this@HomeActivity) MaterialAlertDialogBuilder(this@HomeActivity)
.setTitle(R.string.dialog_title_error) .setTitle(R.string.dialog_title_error)
.setMessage(if (isMatrixToLink) R.string.permalink_malformed else R.string.universal_link_malformed) .setMessage(if (isMatrixToLink) R.string.permalink_malformed else R.string.universal_link_malformed)

View file

@ -51,7 +51,6 @@ import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
import org.matrix.android.sdk.internal.util.awaitCallback import org.matrix.android.sdk.internal.util.awaitCallback
import org.matrix.android.sdk.rx.asObservable
import timber.log.Timber import timber.log.Timber
import kotlin.coroutines.Continuation import kotlin.coroutines.Continuation
import kotlin.coroutines.resume import kotlin.coroutines.resume

View file

@ -102,8 +102,7 @@ class UnknownDeviceDetectorSharedViewModel @AssistedInject constructor(@Assisted
session.flow().liveUserCryptoDevices(session.myUserId), session.flow().liveUserCryptoDevices(session.myUserId),
session.flow().liveMyDevicesInfo(), session.flow().liveMyDevicesInfo(),
session.flow().liveCrossSigningPrivateKeys() session.flow().liveCrossSigningPrivateKeys()
) ) { cryptoList, infoList, pInfo ->
{ cryptoList, infoList, pInfo ->
// Timber.v("## Detector trigger ${cryptoList.map { "${it.deviceId} ${it.trustLevel}" }}") // Timber.v("## Detector trigger ${cryptoList.map { "${it.deviceId} ${it.trustLevel}" }}")
// Timber.v("## Detector trigger canCrossSign ${pInfo.get().selfSigned != null}") // Timber.v("## Detector trigger canCrossSign ${pInfo.get().selfSigned != null}")
infoList infoList

View file

@ -25,7 +25,6 @@ import dagger.assisted.AssistedInject
import im.vector.app.core.platform.EmptyAction import im.vector.app.core.platform.EmptyAction
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import io.reactivex.schedulers.Schedulers
import org.matrix.android.sdk.api.query.QueryStringValue import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.Membership

View file

@ -184,8 +184,6 @@ import im.vector.app.features.widgets.WidgetActivity
import im.vector.app.features.widgets.WidgetArgs import im.vector.app.features.widgets.WidgetArgs
import im.vector.app.features.widgets.WidgetKind import im.vector.app.features.widgets.WidgetKind
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionBottomSheet import im.vector.app.features.widgets.permissions.RoomWidgetPermissionBottomSheet
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import kotlinx.parcelize.Parcelize import kotlinx.parcelize.Parcelize
import nl.dionsegijn.konfetti.models.Shape import nl.dionsegijn.konfetti.models.Shape

View file

@ -17,7 +17,7 @@
package im.vector.app.features.home.room.detail.composer package im.vector.app.features.home.room.detail.composer
import com.airbnb.mvrx.FragmentViewModelContext import com.airbnb.mvrx.FragmentViewModelContext
import com.airbnb.mvrx.MvRxViewModelFactory import com.airbnb.mvrx.MavericksViewModelFactory
import com.airbnb.mvrx.ViewModelContext import com.airbnb.mvrx.ViewModelContext
import dagger.assisted.Assisted import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory import dagger.assisted.AssistedFactory
@ -707,7 +707,7 @@ class TextComposerViewModel @AssistedInject constructor(
fun create(initialState: TextComposerViewState): TextComposerViewModel fun create(initialState: TextComposerViewState): TextComposerViewModel
} }
companion object : MvRxViewModelFactory<TextComposerViewModel, TextComposerViewState> { companion object : MavericksViewModelFactory<TextComposerViewModel, TextComposerViewState> {
@JvmStatic @JvmStatic
override fun create(viewModelContext: ViewModelContext, state: TextComposerViewState): TextComposerViewModel { override fun create(viewModelContext: ViewModelContext, state: TextComposerViewState): TextComposerViewModel {

View file

@ -16,6 +16,7 @@
package im.vector.app.features.home.room.detail.composer package im.vector.app.features.home.room.detail.composer
import com.airbnb.mvrx.MavericksState
import com.airbnb.mvrx.MvRxState import com.airbnb.mvrx.MvRxState
import im.vector.app.features.home.room.detail.RoomDetailArgs import im.vector.app.features.home.room.detail.RoomDetailArgs
import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent import org.matrix.android.sdk.api.session.room.timeline.TimelineEvent
@ -47,7 +48,7 @@ data class TextComposerViewState(
val isVoiceRecording: Boolean = false, val isVoiceRecording: Boolean = false,
val isSendButtonVisible: Boolean = false, val isSendButtonVisible: Boolean = false,
val sendMode: SendMode = SendMode.REGULAR("", false) val sendMode: SendMode = SendMode.REGULAR("", false)
) : MvRxState { ) : MavericksState {
val isComposerVisible: Boolean val isComposerVisible: Boolean
get() = canSendMessage && !isVoiceRecording get() = canSendMessage && !isVoiceRecording

View file

@ -43,8 +43,8 @@ import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState import org.matrix.android.sdk.api.session.room.members.ChangeMembershipState
import org.matrix.android.sdk.api.session.room.model.tag.RoomTag import org.matrix.android.sdk.api.session.room.model.tag.RoomTag
import org.matrix.android.sdk.api.session.room.state.isPublic import org.matrix.android.sdk.api.session.room.state.isPublic
import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.api.util.toMatrixItem import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.flow.flow
import timber.log.Timber import timber.log.Timber
import javax.inject.Inject import javax.inject.Inject

View file

@ -30,10 +30,7 @@ import im.vector.app.features.userdirectory.PendingSelection
import kotlinx.coroutines.flow.asFlow import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.collect import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onCompletion
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session

View file

@ -32,8 +32,6 @@ import org.matrix.android.sdk.api.session.permalinks.PermalinkParser
import org.matrix.android.sdk.api.session.permalinks.PermalinkService import org.matrix.android.sdk.api.session.permalinks.PermalinkService
import org.matrix.android.sdk.api.session.room.model.Membership import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.model.RoomType import org.matrix.android.sdk.api.session.room.model.RoomType
import org.matrix.android.sdk.api.util.Optional
import org.matrix.android.sdk.api.util.toOptional
import javax.inject.Inject import javax.inject.Inject
class PermalinkHandler @Inject constructor(private val activeSessionHolder: ActiveSessionHolder, class PermalinkHandler @Inject constructor(private val activeSessionHolder: ActiveSessionHolder,

View file

@ -18,8 +18,8 @@ package im.vector.app.features.pin
import android.content.Context import android.content.Context
import android.content.Intent import android.content.Intent
import com.google.android.material.appbar.MaterialToolbar
import com.airbnb.mvrx.Mavericks import com.airbnb.mvrx.Mavericks
import com.google.android.material.appbar.MaterialToolbar
import im.vector.app.R import im.vector.app.R
import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragment
import im.vector.app.core.platform.ToolbarConfigurable import im.vector.app.core.platform.ToolbarConfigurable

View file

@ -27,19 +27,14 @@ import im.vector.app.R
import im.vector.app.core.extensions.exhaustive import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.StringProvider
import io.reactivex.Observable
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asFlow
import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.subscribe
import kotlinx.coroutines.flow.switchMap
import org.matrix.android.sdk.api.query.QueryStringValue import org.matrix.android.sdk.api.query.QueryStringValue
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.EventType import org.matrix.android.sdk.api.session.events.model.EventType
@ -86,7 +81,7 @@ class RequireActiveMembershipViewModel @AssistedInject constructor(
roomIdFlow roomIdFlow
.unwrap() .unwrap()
.flatMapLatest { roomId -> .flatMapLatest { roomId ->
val room = session.getRoom(roomId) ?: return@flatMapLatest flow{ val room = session.getRoom(roomId) ?: return@flatMapLatest flow {
val emptyResult = Optional.empty<RequireActiveMembershipViewEvents.RoomLeft>() val emptyResult = Optional.empty<RequireActiveMembershipViewEvents.RoomLeft>()
emit(emptyResult) emit(emptyResult)
} }

View file

@ -31,8 +31,8 @@ import im.vector.app.R
import im.vector.app.core.mvrx.runCatchingToAsync import im.vector.app.core.mvrx.runCatchingToAsync
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.core.resources.StringProvider import im.vector.app.core.resources.StringProvider
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
import im.vector.app.features.displayname.getBestName import im.vector.app.features.displayname.getBestName
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn

View file

@ -28,7 +28,6 @@ import im.vector.app.core.extensions.exhaustive
import im.vector.app.core.platform.EmptyViewEvents import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import im.vector.app.features.powerlevel.PowerLevelsFlowFactory import im.vector.app.features.powerlevel.PowerLevelsFlowFactory
import io.reactivex.android.schedulers.AndroidSchedulers
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.catch import kotlinx.coroutines.flow.catch
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
@ -37,7 +36,6 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.switchMap
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel import org.matrix.android.sdk.api.crypto.RoomEncryptionTrustLevel
import org.matrix.android.sdk.api.extensions.orFalse import org.matrix.android.sdk.api.extensions.orFalse
@ -99,11 +97,9 @@ class RoomMemberListViewModel @AssistedInject constructor(@Assisted initialState
.liveStateEvent(EventType.STATE_ROOM_POWER_LEVELS, QueryStringValue.NoCondition) .liveStateEvent(EventType.STATE_ROOM_POWER_LEVELS, QueryStringValue.NoCondition)
.mapOptional { it.content.toModel<PowerLevelsContent>() } .mapOptional { it.content.toModel<PowerLevelsContent>() }
.unwrap() .unwrap()
) ) { roomMembers, powerLevelsContent ->
{ roomMembers, powerLevelsContent ->
buildRoomMemberSummaries(powerLevelsContent, roomMembers) buildRoomMemberSummaries(powerLevelsContent, roomMembers)
} }
.execute { async -> .execute { async ->
copy(roomMemberSummaries = async) copy(roomMemberSummaries = async)
} }

View file

@ -301,7 +301,7 @@ class RoomSettingsViewModel @AssistedInject constructor(@Assisted initialState:
_viewEvents.post(RoomSettingsViewEvents.Success) _viewEvents.post(RoomSettingsViewEvents.Success)
} catch (failure: Throwable) { } catch (failure: Throwable) {
_viewEvents.post(RoomSettingsViewEvents.Failure(failure)) _viewEvents.post(RoomSettingsViewEvents.Failure(failure))
}finally { } finally {
updateLoadingState(isLoading = false) updateLoadingState(isLoading = false)
} }
} }

View file

@ -58,7 +58,6 @@ import im.vector.app.features.pin.PinMode
import im.vector.app.features.raw.wellknown.getElementWellknown import im.vector.app.features.raw.wellknown.getElementWellknown
import im.vector.app.features.raw.wellknown.isE2EByDefault import im.vector.app.features.raw.wellknown.isE2EByDefault
import im.vector.app.features.themes.ThemeUtils import im.vector.app.features.themes.ThemeUtils
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable import io.reactivex.disposables.Disposable
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.flowOn

View file

@ -58,8 +58,7 @@ class CrossSigningSettingsViewModel @AssistedInject constructor(
combine( combine(
session.flow().liveMyDevicesInfo(), session.flow().liveMyDevicesInfo(),
session.flow().liveCrossSigningInfo(session.myUserId) session.flow().liveCrossSigningInfo(session.myUserId)
) ) { myDevicesInfo, mxCrossSigningInfo ->
{ myDevicesInfo, mxCrossSigningInfo ->
myDevicesInfo to mxCrossSigningInfo myDevicesInfo to mxCrossSigningInfo
} }
.execute { data -> .execute { data ->

View file

@ -125,8 +125,7 @@ class DevicesViewModel @AssistedInject constructor(
combine( combine(
session.flow().liveUserCryptoDevices(session.myUserId), session.flow().liveUserCryptoDevices(session.myUserId),
session.flow().liveMyDevicesInfo() session.flow().liveMyDevicesInfo()
) ) { cryptoList, infoList ->
{ cryptoList, infoList ->
infoList infoList
.sortedByDescending { it.lastSeenTs } .sortedByDescending { it.lastSeenTs }
.map { deviceInfo -> .map { deviceInfo ->

View file

@ -33,7 +33,6 @@ import im.vector.app.core.platform.EmptyViewEvents
import im.vector.app.core.platform.VectorViewModel import im.vector.app.core.platform.VectorViewModel
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.Event
import org.matrix.android.sdk.rx.asObservable
data class GossipingEventsPaperTrailState( data class GossipingEventsPaperTrailState(
val events: Async<PagedList<Event>> = Uninitialized val events: Async<PagedList<Event>> = Uninitialized

View file

@ -35,7 +35,6 @@ import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.Session
import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest import org.matrix.android.sdk.internal.crypto.IncomingRoomKeyRequest
import org.matrix.android.sdk.internal.crypto.OutgoingRoomKeyRequest import org.matrix.android.sdk.internal.crypto.OutgoingRoomKeyRequest
import org.matrix.android.sdk.rx.asObservable
data class KeyRequestListViewState( data class KeyRequestListViewState(
val incomingRequests: Async<PagedList<IncomingRoomKeyRequest>> = Uninitialized, val incomingRequests: Async<PagedList<IncomingRoomKeyRequest>> = Uninitialized,

View file

@ -33,13 +33,11 @@ import im.vector.app.features.session.coroutineScope
import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.settings.VectorPreferences
import im.vector.app.group import im.vector.app.group
import im.vector.app.space import im.vector.app.space
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.combine import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.map import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.observeOn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.sample import kotlinx.coroutines.flow.sample
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -60,8 +58,6 @@ import org.matrix.android.sdk.api.session.space.model.SpaceOrderContent
import org.matrix.android.sdk.api.session.space.model.TopLevelSpaceComparator import org.matrix.android.sdk.api.session.space.model.TopLevelSpaceComparator
import org.matrix.android.sdk.api.util.toMatrixItem import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.flow.flow import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.rx.asObservable
import java.util.concurrent.TimeUnit
class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: SpaceListViewState, class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: SpaceListViewState,
private val appStateHandler: AppStateHandler, private val appStateHandler: AppStateHandler,
@ -92,7 +88,7 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
.asFlow() .asFlow()
.setOnEach { .setOnEach {
copy( copy(
myMxItem = it?.getOrNull()?.toMatrixItem()?.let { Success(it) } ?: Loading() myMxItem = it.getOrNull()?.toMatrixItem()?.let { Success(it) } ?: Loading()
) )
} }

View file

@ -24,8 +24,8 @@ import android.widget.Toast
import androidx.core.app.ActivityCompat import androidx.core.app.ActivityCompat
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import com.airbnb.mvrx.Mavericks
import androidx.fragment.app.FragmentManager import androidx.fragment.app.FragmentManager
import com.airbnb.mvrx.Mavericks
import com.airbnb.mvrx.viewModel import com.airbnb.mvrx.viewModel
import com.airbnb.mvrx.withState import com.airbnb.mvrx.withState
import im.vector.app.R import im.vector.app.R