From 006b212189d87530ebce873122b0ba8924965e4e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 13 Jan 2022 21:19:52 +0100 Subject: [PATCH] Change remaining `Observable` to something more accurate --- vector/src/main/java/im/vector/app/AppStateHandler.kt | 2 +- .../main/java/im/vector/app/core/di/ActiveSessionHolder.kt | 6 +++--- .../java/im/vector/app/features/home/HomeDetailViewModel.kt | 4 ++-- .../vector/app/features/home/PromoteRestrictedViewModel.kt | 2 +- .../app/features/home/UnreadMessagesSharedViewModel.kt | 4 ++-- .../features/home/room/list/RoomListSectionBuilderGroup.kt | 2 +- .../features/home/room/list/RoomListSectionBuilderSpace.kt | 4 ++-- .../vector/app/features/home/room/list/RoomListViewModel.kt | 2 +- .../im/vector/app/features/spaces/SpaceListViewModel.kt | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/vector/src/main/java/im/vector/app/AppStateHandler.kt b/vector/src/main/java/im/vector/app/AppStateHandler.kt index 9ed9dd5b23..2a3d2cd87f 100644 --- a/vector/src/main/java/im/vector/app/AppStateHandler.kt +++ b/vector/src/main/java/im/vector/app/AppStateHandler.kt @@ -61,7 +61,7 @@ class AppStateHandler @Inject constructor( private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main) private val selectedSpaceDataSource = BehaviorDataSource>(Option.empty()) - val selectedRoomGroupingObservable = selectedSpaceDataSource.stream() + val selectedRoomGroupingFlow = selectedSpaceDataSource.stream() fun getCurrentRoomGroupingMethod(): RoomGroupingMethod? { // XXX we should somehow make it live :/ just a work around diff --git a/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt b/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt index 5d8d5db3fe..4883676f87 100644 --- a/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt +++ b/vector/src/main/java/im/vector/app/core/di/ActiveSessionHolder.kt @@ -31,7 +31,7 @@ import javax.inject.Inject import javax.inject.Singleton @Singleton -class ActiveSessionHolder @Inject constructor(private val sessionObservableStore: ActiveSessionDataSource, +class ActiveSessionHolder @Inject constructor(private val activeSessionDataSource: ActiveSessionDataSource, private val keyRequestHandler: KeyRequestHandler, private val incomingVerificationRequestHandler: IncomingVerificationRequestHandler, private val callManager: WebRtcCallManager, @@ -46,7 +46,7 @@ class ActiveSessionHolder @Inject constructor(private val sessionObservableStore fun setActiveSession(session: Session) { Timber.w("setActiveSession of ${session.myUserId}") activeSession.set(session) - sessionObservableStore.post(Option.just(session)) + activeSessionDataSource.post(Option.just(session)) keyRequestHandler.start(session) incomingVerificationRequestHandler.start(session) @@ -66,7 +66,7 @@ class ActiveSessionHolder @Inject constructor(private val sessionObservableStore } activeSession.set(null) - sessionObservableStore.post(Option.empty()) + activeSessionDataSource.post(Option.empty()) keyRequestHandler.stop() incomingVerificationRequestHandler.stop() diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt index f284de9d48..d7239373bd 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailViewModel.kt @@ -197,7 +197,7 @@ class HomeDetailViewModel @AssistedInject constructor( } private fun observeRoomGroupingMethod() { - appStateHandler.selectedRoomGroupingObservable + appStateHandler.selectedRoomGroupingFlow .setOnEach { copy( roomGroupingMethod = it.orNull() ?: RoomGroupingMethod.BySpace(null) @@ -206,7 +206,7 @@ class HomeDetailViewModel @AssistedInject constructor( } private fun observeRoomSummaries() { - appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged().flatMapLatest { + appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().flatMapLatest { // we use it as a trigger to all changes in room, but do not really load // the actual models session.getPagedRoomSummariesLive( diff --git a/vector/src/main/java/im/vector/app/features/home/PromoteRestrictedViewModel.kt b/vector/src/main/java/im/vector/app/features/home/PromoteRestrictedViewModel.kt index 77ee23f732..5c66e7c52d 100644 --- a/vector/src/main/java/im/vector/app/features/home/PromoteRestrictedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/PromoteRestrictedViewModel.kt @@ -50,7 +50,7 @@ class PromoteRestrictedViewModel @AssistedInject constructor( ) : VectorViewModel(initialState) { init { - appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged().execute { state -> + appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().execute { state -> val groupingMethod = state.invoke()?.orNull() val isSpaceMode = groupingMethod is RoomGroupingMethod.BySpace val currentSpace = (groupingMethod as? RoomGroupingMethod.BySpace)?.spaceSummary diff --git a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt index b65a85eb00..409eb0b845 100644 --- a/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/UnreadMessagesSharedViewModel.kt @@ -107,8 +107,8 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia } combine( - appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged(), - appStateHandler.selectedRoomGroupingObservable.flatMapLatest { + appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged(), + appStateHandler.selectedRoomGroupingFlow.flatMapLatest { session.getPagedRoomSummariesLive( roomSummaryQueryParams { this.memberships = Membership.activeMemberships() diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt index 58db2a4030..77f61149f8 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderGroup.kt @@ -104,7 +104,7 @@ class RoomListSectionBuilderGroup( } } - appStateHandler.selectedRoomGroupingObservable + appStateHandler.selectedRoomGroupingFlow .distinctUntilChanged() .onEach { groupingMethod -> val selectedGroupId = (groupingMethod.orNull() as? RoomGroupingMethod.ByLegacyGroup)?.groupSummary?.groupId diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt index bde324e57b..296e61690b 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListSectionBuilderSpace.kt @@ -132,7 +132,7 @@ class RoomListSectionBuilderSpace( } } - appStateHandler.selectedRoomGroupingObservable + appStateHandler.selectedRoomGroupingFlow .distinctUntilChanged() .onEach { groupingMethod -> val selectedSpace = groupingMethod.orNull()?.space() @@ -222,7 +222,7 @@ class RoomListSectionBuilderSpace( // add suggested rooms val suggestedRoomsFlow = // MutableLiveData>() - appStateHandler.selectedRoomGroupingObservable + appStateHandler.selectedRoomGroupingFlow .distinctUntilChanged() .flatMapLatest { groupingMethod -> val selectedSpace = groupingMethod.orNull()?.space() diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt index e5caaffbda..46a91e2c72 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListViewModel.kt @@ -92,7 +92,7 @@ class RoomListViewModel @AssistedInject constructor( init { observeMembershipChanges() - appStateHandler.selectedRoomGroupingObservable + appStateHandler.selectedRoomGroupingFlow .distinctUntilChanged() .execute { copy( diff --git a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt index a762e13cba..02771abc95 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/SpaceListViewModel.kt @@ -88,7 +88,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa observeSpaceSummaries() // observeSelectionState() - appStateHandler.selectedRoomGroupingObservable + appStateHandler.selectedRoomGroupingFlow .distinctUntilChanged() .setOnEach { copy(