Mavericks 2: continue removing rx
This commit is contained in:
parent
578358d839
commit
79ec0591d2
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.call.conference
|
||||
|
||||
import androidx.lifecycle.asFlow
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.airbnb.mvrx.Fail
|
||||
import com.airbnb.mvrx.MavericksViewModelFactory
|
||||
|
@ -28,7 +29,11 @@ import dagger.assisted.AssistedInject
|
|||
import im.vector.app.core.extensions.exhaustive
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import io.reactivex.disposables.Disposable
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.query.QueryStringValue
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
@ -47,7 +52,7 @@ class JitsiCallViewModel @AssistedInject constructor(
|
|||
fun create(initialState: JitsiCallViewState): JitsiCallViewModel
|
||||
}
|
||||
|
||||
private var currentWidgetObserver: Disposable? = null
|
||||
private var currentWidgetObserver: Job? = null
|
||||
private val widgetService = session.widgetService()
|
||||
|
||||
private var confIsJoined = false
|
||||
|
@ -59,11 +64,11 @@ class JitsiCallViewModel @AssistedInject constructor(
|
|||
|
||||
private fun observeWidget(roomId: String, widgetId: String) {
|
||||
confIsJoined = false
|
||||
currentWidgetObserver?.dispose()
|
||||
currentWidgetObserver?.cancel()
|
||||
currentWidgetObserver = widgetService.getRoomWidgetsLive(roomId, QueryStringValue.Equals(widgetId), WidgetType.Jitsi.values())
|
||||
.asObservable()
|
||||
.asFlow()
|
||||
.distinctUntilChanged()
|
||||
.subscribe {
|
||||
.onEach {
|
||||
val jitsiWidget = it.firstOrNull()
|
||||
if (jitsiWidget != null) {
|
||||
setState {
|
||||
|
@ -81,7 +86,7 @@ class JitsiCallViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
}
|
||||
.disposeOnClear()
|
||||
.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
private fun joinConference(jitsiWidget: Widget) = withState { state ->
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.matrix.android.sdk.api.session.securestorage.KeyInfoResult
|
|||
import org.matrix.android.sdk.api.session.securestorage.RawBytesKeySpec
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.internal.crypto.crosssigning.toBase64NoPadding
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import timber.log.Timber
|
||||
import java.io.ByteArrayOutputStream
|
||||
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.matrix.android.sdk.api.session.room.model.message.MessageContent
|
|||
import org.matrix.android.sdk.api.util.JsonDict
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.internal.di.MoshiProvider
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
|
||||
class RoomDevToolViewModel @AssistedInject constructor(
|
||||
@Assisted val initialState: RoomDevToolViewState,
|
||||
|
|
|
@ -52,7 +52,6 @@ import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
|||
import org.matrix.android.sdk.internal.crypto.model.MXUsersDevicesMap
|
||||
import org.matrix.android.sdk.internal.util.awaitCallback
|
||||
import org.matrix.android.sdk.rx.asObservable
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import timber.log.Timber
|
||||
import kotlin.coroutines.Continuation
|
||||
import kotlin.coroutines.resume
|
||||
|
|
|
@ -31,7 +31,6 @@ 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.roomSummaryQueryParams
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
|
||||
class BreadcrumbsViewModel @AssistedInject constructor(@Assisted initialState: BreadcrumbsViewState,
|
||||
private val session: Session)
|
||||
|
|
|
@ -36,7 +36,6 @@ import kotlinx.coroutines.flow.onCompletion
|
|||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
|
||||
class InviteUsersToRoomViewModel @AssistedInject constructor(@Assisted
|
||||
initialState: InviteUsersToRoomViewState,
|
||||
|
|
|
@ -24,13 +24,14 @@ import dagger.assisted.Assisted
|
|||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.MatrixPatterns
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import org.matrix.android.sdk.rx.unwrap
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.flow.unwrap
|
||||
import timber.log.Timber
|
||||
|
||||
class AccountCreatedViewModel @AssistedInject constructor(
|
||||
|
@ -62,7 +63,7 @@ class AccountCreatedViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun observeUser() {
|
||||
session.rx()
|
||||
session.flow()
|
||||
.liveUser(session.myUserId)
|
||||
.unwrap()
|
||||
.map {
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.matrix.android.sdk.api.session.room.model.Membership
|
|||
import org.matrix.android.sdk.api.session.room.peeking.PeekResult
|
||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import timber.log.Timber
|
||||
|
||||
class RoomPreviewViewModel @AssistedInject constructor(@Assisted private val initialState: RoomPreviewViewState,
|
||||
|
|
|
@ -35,7 +35,6 @@ import org.matrix.android.sdk.api.util.MatrixItem
|
|||
import org.matrix.android.sdk.api.util.toMatrixItem
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.internal.crypto.model.CryptoDeviceInfo
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
|
||||
data class DeviceListViewState(
|
||||
val userItem: MatrixItem? = null,
|
||||
|
|
|
@ -42,8 +42,6 @@ import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
|||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.flow.mapOptional
|
||||
import org.matrix.android.sdk.flow.unwrap
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import org.matrix.android.sdk.rx.unwrap
|
||||
|
||||
class RoomAliasViewModel @AssistedInject constructor(@Assisted initialState: RoomAliasViewState,
|
||||
private val session: Session)
|
||||
|
|
|
@ -40,8 +40,6 @@ import org.matrix.android.sdk.api.session.room.model.RoomMemberSummary
|
|||
import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.flow.unwrap
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import org.matrix.android.sdk.rx.unwrap
|
||||
|
||||
class RoomBannedMemberListViewModel @AssistedInject constructor(@Assisted initialState: RoomBannedMemberListViewState,
|
||||
private val stringProvider: StringProvider,
|
||||
|
|
|
@ -30,8 +30,6 @@ import kotlinx.coroutines.launch
|
|||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.flow.unwrap
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import org.matrix.android.sdk.rx.unwrap
|
||||
|
||||
class RoomNotificationSettingsViewModel @AssistedInject constructor(
|
||||
@Assisted initialState: RoomNotificationSettingsViewState,
|
||||
|
@ -74,7 +72,7 @@ class RoomNotificationSettingsViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
private fun observeNotificationState() {
|
||||
room.rx()
|
||||
room.flow()
|
||||
.liveNotificationState()
|
||||
.execute {
|
||||
copy(notificationState = it)
|
||||
|
|
|
@ -72,7 +72,6 @@ import org.matrix.android.sdk.internal.crypto.crosssigning.isVerified
|
|||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.DevicesListResponse
|
||||
import org.matrix.android.sdk.rx.SecretsSynchronisationInfo
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import javax.inject.Inject
|
||||
|
||||
class VectorSettingsSecurityPrivacyFragment @Inject constructor(
|
||||
|
|
|
@ -29,7 +29,6 @@ import kotlinx.coroutines.flow.map
|
|||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.internal.crypto.model.rest.DeviceInfo
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
|
||||
class DeviceVerificationInfoBottomSheetViewModel @AssistedInject constructor(@Assisted initialState: DeviceVerificationInfoBottomSheetViewState,
|
||||
@Assisted val deviceId: String,
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.settings.devtools
|
||||
|
||||
import androidx.lifecycle.asFlow
|
||||
import androidx.paging.PagedList
|
||||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.FragmentViewModelContext
|
||||
|
@ -50,7 +51,8 @@ class GossipingEventsPaperTrailViewModel @AssistedInject constructor(@Assisted i
|
|||
setState {
|
||||
copy(events = Loading())
|
||||
}
|
||||
session.cryptoService().getGossipingEventsTrail().asObservable()
|
||||
session.cryptoService().getGossipingEventsTrail()
|
||||
.asFlow()
|
||||
.execute {
|
||||
copy(events = it)
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package im.vector.app.features.settings.devtools
|
||||
|
||||
import androidx.lifecycle.asFlow
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.paging.PagedList
|
||||
import com.airbnb.mvrx.Async
|
||||
|
@ -51,13 +52,13 @@ class KeyRequestListViewModel @AssistedInject constructor(@Assisted initialState
|
|||
|
||||
fun refresh() {
|
||||
viewModelScope.launch {
|
||||
session.cryptoService().getOutgoingRoomKeyRequestsPaged().asObservable()
|
||||
session.cryptoService().getOutgoingRoomKeyRequestsPaged().asFlow()
|
||||
.execute {
|
||||
copy(outgoingRoomKeyRequests = it)
|
||||
}
|
||||
|
||||
session.cryptoService().getIncomingRoomKeyRequestsPaged()
|
||||
.asObservable()
|
||||
.asFlow()
|
||||
.execute {
|
||||
copy(incomingRequests = it)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
|
||||
package im.vector.app.features.settings.push
|
||||
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.airbnb.mvrx.Async
|
||||
import com.airbnb.mvrx.FragmentViewModelContext
|
||||
import com.airbnb.mvrx.MavericksState
|
||||
|
@ -31,7 +30,7 @@ import im.vector.app.core.platform.VectorViewModel
|
|||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import org.matrix.android.sdk.api.session.pushers.Pusher
|
||||
import org.matrix.android.sdk.rx.RxSession
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
|
||||
data class PushGatewayViewState(
|
||||
val pushGateways: Async<List<Pusher>> = Uninitialized
|
||||
|
@ -62,7 +61,7 @@ class PushGatewaysViewModel @AssistedInject constructor(@Assisted initialState:
|
|||
}
|
||||
|
||||
private fun observePushers() {
|
||||
RxSession(session)
|
||||
session.flow()
|
||||
.livePushers()
|
||||
.execute {
|
||||
copy(pushGateways = it)
|
||||
|
|
|
@ -43,7 +43,6 @@ import org.matrix.android.sdk.api.session.room.powerlevels.PowerLevelsHelper
|
|||
import org.matrix.android.sdk.api.session.room.powerlevels.Role
|
||||
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
|
||||
import org.matrix.android.sdk.flow.flow
|
||||
import org.matrix.android.sdk.rx.rx
|
||||
import timber.log.Timber
|
||||
|
||||
class SpaceMenuViewModel @AssistedInject constructor(
|
||||
|
|
|
@ -34,8 +34,14 @@ import im.vector.app.features.settings.VectorPreferences
|
|||
import im.vector.app.group
|
||||
import im.vector.app.space
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.combine
|
||||
import kotlinx.coroutines.flow.flowOn
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.flow.observeOn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import kotlinx.coroutines.flow.sample
|
||||
import kotlinx.coroutines.launch
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.query.ActiveSpaceFilter
|
||||
|
@ -82,14 +88,13 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
|
|||
|
||||
init {
|
||||
|
||||
session.getUserLive(session.myUserId).asObservable()
|
||||
.subscribe {
|
||||
setState {
|
||||
copy(
|
||||
myMxItem = it?.getOrNull()?.toMatrixItem()?.let { Success(it) } ?: Loading()
|
||||
)
|
||||
}
|
||||
}.disposeOnClear()
|
||||
session.getUserLive(session.myUserId)
|
||||
.asFlow()
|
||||
.setOnEach {
|
||||
copy(
|
||||
myMxItem = it?.getOrNull()?.toMatrixItem()?.let { Success(it) } ?: Loading()
|
||||
)
|
||||
}
|
||||
|
||||
observeSpaceSummaries()
|
||||
// observeSelectionState()
|
||||
|
@ -105,14 +110,10 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
|
|||
.disposeOnClear()
|
||||
|
||||
session.getGroupSummariesLive(groupSummaryQueryParams {})
|
||||
.asObservable()
|
||||
.subscribe {
|
||||
setState {
|
||||
copy(
|
||||
legacyGroups = it
|
||||
)
|
||||
}
|
||||
}.disposeOnClear()
|
||||
.asFlow()
|
||||
.setOnEach {
|
||||
copy(legacyGroups = it)
|
||||
}
|
||||
|
||||
// XXX there should be a way to refactor this and share it
|
||||
session.getPagedRoomSummariesLive(
|
||||
|
@ -122,10 +123,10 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
|
|||
!vectorPreferences.prefSpacesShowAllRoomInHome()
|
||||
} ?: ActiveSpaceFilter.None
|
||||
}, sortOrder = RoomSortOrder.NONE
|
||||
).asObservable()
|
||||
.throttleFirst(300, TimeUnit.MILLISECONDS)
|
||||
.observeOn(Schedulers.computation())
|
||||
.subscribe {
|
||||
).asFlow()
|
||||
.sample(300)
|
||||
.flowOn(Dispatchers.Default)
|
||||
.onEach {
|
||||
val inviteCount = if (autoAcceptInvites.hideInvites) {
|
||||
0
|
||||
} else {
|
||||
|
@ -150,7 +151,7 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
|
|||
homeAggregateCount = counts
|
||||
)
|
||||
}
|
||||
}.disposeOnClear()
|
||||
}.launchIn(viewModelScope)
|
||||
}
|
||||
|
||||
override fun handle(action: SpaceListAction) {
|
||||
|
@ -319,7 +320,8 @@ class SpacesListViewModel @AssistedInject constructor(@Assisted initialState: Sp
|
|||
// clear local echos on update
|
||||
session.accountDataService()
|
||||
.getLiveRoomAccountDataEvents(setOf(RoomAccountDataTypes.EVENT_TYPE_SPACE_ORDER))
|
||||
.asObservable().execute {
|
||||
.asFlow()
|
||||
.execute {
|
||||
copy(
|
||||
spaceOrderLocalEchos = emptyMap()
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue