mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-25 10:55:55 +03:00
Change remaining Observable
to something more accurate
This commit is contained in:
parent
9a42e1e8c3
commit
006b212189
9 changed files with 14 additions and 14 deletions
|
@ -61,7 +61,7 @@ class AppStateHandler @Inject constructor(
|
|||
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||
private val selectedSpaceDataSource = BehaviorDataSource<Option<RoomGroupingMethod>>(Option.empty())
|
||||
|
||||
val selectedRoomGroupingObservable = selectedSpaceDataSource.stream()
|
||||
val selectedRoomGroupingFlow = selectedSpaceDataSource.stream()
|
||||
|
||||
fun getCurrentRoomGroupingMethod(): RoomGroupingMethod? {
|
||||
// XXX we should somehow make it live :/ just a work around
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -50,7 +50,7 @@ class PromoteRestrictedViewModel @AssistedInject constructor(
|
|||
) : VectorViewModel<ActiveSpaceViewState, EmptyAction, EmptyViewEvents>(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
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -104,7 +104,7 @@ class RoomListSectionBuilderGroup(
|
|||
}
|
||||
}
|
||||
|
||||
appStateHandler.selectedRoomGroupingObservable
|
||||
appStateHandler.selectedRoomGroupingFlow
|
||||
.distinctUntilChanged()
|
||||
.onEach { groupingMethod ->
|
||||
val selectedGroupId = (groupingMethod.orNull() as? RoomGroupingMethod.ByLegacyGroup)?.groupSummary?.groupId
|
||||
|
|
|
@ -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<List<SpaceChildInfo>>()
|
||||
appStateHandler.selectedRoomGroupingObservable
|
||||
appStateHandler.selectedRoomGroupingFlow
|
||||
.distinctUntilChanged()
|
||||
.flatMapLatest { groupingMethod ->
|
||||
val selectedSpace = groupingMethod.orNull()?.space()
|
||||
|
|
|
@ -92,7 +92,7 @@ class RoomListViewModel @AssistedInject constructor(
|
|||
init {
|
||||
observeMembershipChanges()
|
||||
|
||||
appStateHandler.selectedRoomGroupingObservable
|
||||
appStateHandler.selectedRoomGroupingFlow
|
||||
.distinctUntilChanged()
|
||||
.execute {
|
||||
copy(
|
||||
|
|
|
@ -88,7 +88,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
|||
|
||||
observeSpaceSummaries()
|
||||
// observeSelectionState()
|
||||
appStateHandler.selectedRoomGroupingObservable
|
||||
appStateHandler.selectedRoomGroupingFlow
|
||||
.distinctUntilChanged()
|
||||
.setOnEach {
|
||||
copy(
|
||||
|
|
Loading…
Reference in a new issue