Flow: remove more rx

This commit is contained in:
ganfra 2021-10-26 15:16:10 +02:00
parent c936954119
commit 9479342a64
9 changed files with 12 additions and 20 deletions

View file

@ -102,7 +102,6 @@ ext.libs = [
'epoxyProcessor' : "com.airbnb.android:epoxy-processor:$epoxy",
'epoxyPaging' : "com.airbnb.android:epoxy-paging:$epoxy",
'mavericks' : "com.airbnb.android:mavericks:$mavericks",
'mavericksRx' : "com.airbnb.android:mavericks-rxjava2:$mavericks",
'mavericksTesting' : "com.airbnb.android:mavericks-testing:$mavericks"
],
mockk : [

View file

@ -333,7 +333,6 @@ configurations {
dependencies {
implementation project(":matrix-sdk-android")
implementation project(":matrix-sdk-android-rx")
implementation project(":matrix-sdk-android-flow")
implementation project(":diff-match-patch")
implementation project(":multipicker")

View file

@ -247,8 +247,7 @@ class HomeActivity :
}
homeActivityViewModel.onEach { renderState(it) }
shortcutsHandler.observeRoomsAndBuildShortcuts()
.disposeOnDestroy()
shortcutsHandler.observeRoomsAndBuildShortcuts(lifecycleScope)
if (!vectorPreferences.didPromoteNewRestrictedFeature()) {
promoteRestrictedViewModel.onEach {

View file

@ -56,9 +56,7 @@ import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
import org.matrix.android.sdk.api.util.toMatrixItem
import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.rx.asObservable
import timber.log.Timber
import java.util.concurrent.TimeUnit
/**
* View model used to update the home bottom bar notification counts, observe the sync state and

View file

@ -21,13 +21,15 @@ import android.content.pm.ShortcutManager
import android.os.Build
import androidx.core.content.getSystemService
import androidx.core.content.pm.ShortcutManagerCompat
import androidx.lifecycle.asFlow
import im.vector.app.core.di.ActiveSessionHolder
import io.reactivex.disposables.Disposable
import io.reactivex.disposables.Disposables
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.matrix.android.sdk.api.session.room.RoomSortOrder
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
import org.matrix.android.sdk.rx.asObservable
import javax.inject.Inject
class ShortcutsHandler @Inject constructor(
@ -36,12 +38,11 @@ class ShortcutsHandler @Inject constructor(
private val activeSessionHolder: ActiveSessionHolder
) {
fun observeRoomsAndBuildShortcuts(): Disposable {
fun observeRoomsAndBuildShortcuts(coroutineScope: CoroutineScope): Job {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N_MR1) {
// No op
return Disposables.empty()
return Job()
}
return activeSessionHolder.getSafeActiveSession()
?.getPagedRoomSummariesLive(
roomSummaryQueryParams {
@ -49,8 +50,8 @@ class ShortcutsHandler @Inject constructor(
},
sortOrder = RoomSortOrder.PRIORITY_AND_ACTIVITY
)
?.asObservable()
?.subscribe { rooms ->
?.asFlow()
?.onEach { rooms ->
// Remove dead shortcuts (i.e. deleted rooms)
val roomIds = rooms.map { it.roomId }
val deadShortcutIds = ShortcutManagerCompat.getShortcuts(context, ShortcutManagerCompat.FLAG_MATCH_DYNAMIC)
@ -66,7 +67,8 @@ class ShortcutsHandler @Inject constructor(
ShortcutManagerCompat.pushDynamicShortcut(context, shortcut)
}
}
?: Disposables.empty()
?.launchIn(coroutineScope)
?: Job()
}
fun clearShortcuts() {

View file

@ -44,8 +44,6 @@ import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.roomSummaryQueryParams
import org.matrix.android.sdk.api.session.room.spaceSummaryQueryParams
import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
import org.matrix.android.sdk.rx.asObservable
import java.util.concurrent.TimeUnit
data class UnreadMessagesState(
val homeSpaceUnread: RoomAggregateNotificationCount = RoomAggregateNotificationCount(0, 0),

View file

@ -52,7 +52,6 @@ import org.matrix.android.sdk.api.session.room.RoomSummaryQueryParams
import org.matrix.android.sdk.api.session.room.UpdatableLivePageResult
import org.matrix.android.sdk.api.session.room.model.Membership
import org.matrix.android.sdk.api.session.room.summary.RoomAggregateNotificationCount
import org.matrix.android.sdk.rx.asObservable
import timber.log.Timber
class RoomListSectionBuilderSpace(

View file

@ -26,7 +26,6 @@ import org.matrix.android.sdk.api.session.crypto.crosssigning.MASTER_KEY_SSSS_NA
import org.matrix.android.sdk.api.session.crypto.crosssigning.SELF_SIGNING_KEY_SSSS_NAME
import org.matrix.android.sdk.api.session.crypto.crosssigning.USER_SIGNING_KEY_SSSS_NAME
import org.matrix.android.sdk.flow.flow
import org.matrix.android.sdk.rx.SecretsSynchronisationInfo
data class SecretsSynchronisationInfo(
val isBackupSetup: Boolean,

View file

@ -71,7 +71,6 @@ import org.matrix.android.sdk.api.raw.RawService
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 javax.inject.Inject
class VectorSettingsSecurityPrivacyFragment @Inject constructor(