mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-29 06:28:45 +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 coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Main)
|
||||||
private val selectedSpaceDataSource = BehaviorDataSource<Option<RoomGroupingMethod>>(Option.empty())
|
private val selectedSpaceDataSource = BehaviorDataSource<Option<RoomGroupingMethod>>(Option.empty())
|
||||||
|
|
||||||
val selectedRoomGroupingObservable = selectedSpaceDataSource.stream()
|
val selectedRoomGroupingFlow = selectedSpaceDataSource.stream()
|
||||||
|
|
||||||
fun getCurrentRoomGroupingMethod(): RoomGroupingMethod? {
|
fun getCurrentRoomGroupingMethod(): RoomGroupingMethod? {
|
||||||
// XXX we should somehow make it live :/ just a work around
|
// XXX we should somehow make it live :/ just a work around
|
||||||
|
|
|
@ -31,7 +31,7 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ActiveSessionHolder @Inject constructor(private val sessionObservableStore: ActiveSessionDataSource,
|
class ActiveSessionHolder @Inject constructor(private val activeSessionDataSource: ActiveSessionDataSource,
|
||||||
private val keyRequestHandler: KeyRequestHandler,
|
private val keyRequestHandler: KeyRequestHandler,
|
||||||
private val incomingVerificationRequestHandler: IncomingVerificationRequestHandler,
|
private val incomingVerificationRequestHandler: IncomingVerificationRequestHandler,
|
||||||
private val callManager: WebRtcCallManager,
|
private val callManager: WebRtcCallManager,
|
||||||
|
@ -46,7 +46,7 @@ class ActiveSessionHolder @Inject constructor(private val sessionObservableStore
|
||||||
fun setActiveSession(session: Session) {
|
fun setActiveSession(session: Session) {
|
||||||
Timber.w("setActiveSession of ${session.myUserId}")
|
Timber.w("setActiveSession of ${session.myUserId}")
|
||||||
activeSession.set(session)
|
activeSession.set(session)
|
||||||
sessionObservableStore.post(Option.just(session))
|
activeSessionDataSource.post(Option.just(session))
|
||||||
|
|
||||||
keyRequestHandler.start(session)
|
keyRequestHandler.start(session)
|
||||||
incomingVerificationRequestHandler.start(session)
|
incomingVerificationRequestHandler.start(session)
|
||||||
|
@ -66,7 +66,7 @@ class ActiveSessionHolder @Inject constructor(private val sessionObservableStore
|
||||||
}
|
}
|
||||||
|
|
||||||
activeSession.set(null)
|
activeSession.set(null)
|
||||||
sessionObservableStore.post(Option.empty())
|
activeSessionDataSource.post(Option.empty())
|
||||||
|
|
||||||
keyRequestHandler.stop()
|
keyRequestHandler.stop()
|
||||||
incomingVerificationRequestHandler.stop()
|
incomingVerificationRequestHandler.stop()
|
||||||
|
|
|
@ -197,7 +197,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeRoomGroupingMethod() {
|
private fun observeRoomGroupingMethod() {
|
||||||
appStateHandler.selectedRoomGroupingObservable
|
appStateHandler.selectedRoomGroupingFlow
|
||||||
.setOnEach {
|
.setOnEach {
|
||||||
copy(
|
copy(
|
||||||
roomGroupingMethod = it.orNull() ?: RoomGroupingMethod.BySpace(null)
|
roomGroupingMethod = it.orNull() ?: RoomGroupingMethod.BySpace(null)
|
||||||
|
@ -206,7 +206,7 @@ class HomeDetailViewModel @AssistedInject constructor(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun observeRoomSummaries() {
|
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
|
// we use it as a trigger to all changes in room, but do not really load
|
||||||
// the actual models
|
// the actual models
|
||||||
session.getPagedRoomSummariesLive(
|
session.getPagedRoomSummariesLive(
|
||||||
|
|
|
@ -50,7 +50,7 @@ class PromoteRestrictedViewModel @AssistedInject constructor(
|
||||||
) : VectorViewModel<ActiveSpaceViewState, EmptyAction, EmptyViewEvents>(initialState) {
|
) : VectorViewModel<ActiveSpaceViewState, EmptyAction, EmptyViewEvents>(initialState) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged().execute { state ->
|
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged().execute { state ->
|
||||||
val groupingMethod = state.invoke()?.orNull()
|
val groupingMethod = state.invoke()?.orNull()
|
||||||
val isSpaceMode = groupingMethod is RoomGroupingMethod.BySpace
|
val isSpaceMode = groupingMethod is RoomGroupingMethod.BySpace
|
||||||
val currentSpace = (groupingMethod as? RoomGroupingMethod.BySpace)?.spaceSummary
|
val currentSpace = (groupingMethod as? RoomGroupingMethod.BySpace)?.spaceSummary
|
||||||
|
|
|
@ -107,8 +107,8 @@ class UnreadMessagesSharedViewModel @AssistedInject constructor(@Assisted initia
|
||||||
}
|
}
|
||||||
|
|
||||||
combine(
|
combine(
|
||||||
appStateHandler.selectedRoomGroupingObservable.distinctUntilChanged(),
|
appStateHandler.selectedRoomGroupingFlow.distinctUntilChanged(),
|
||||||
appStateHandler.selectedRoomGroupingObservable.flatMapLatest {
|
appStateHandler.selectedRoomGroupingFlow.flatMapLatest {
|
||||||
session.getPagedRoomSummariesLive(
|
session.getPagedRoomSummariesLive(
|
||||||
roomSummaryQueryParams {
|
roomSummaryQueryParams {
|
||||||
this.memberships = Membership.activeMemberships()
|
this.memberships = Membership.activeMemberships()
|
||||||
|
|
|
@ -104,7 +104,7 @@ class RoomListSectionBuilderGroup(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
appStateHandler.selectedRoomGroupingObservable
|
appStateHandler.selectedRoomGroupingFlow
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.onEach { groupingMethod ->
|
.onEach { groupingMethod ->
|
||||||
val selectedGroupId = (groupingMethod.orNull() as? RoomGroupingMethod.ByLegacyGroup)?.groupSummary?.groupId
|
val selectedGroupId = (groupingMethod.orNull() as? RoomGroupingMethod.ByLegacyGroup)?.groupSummary?.groupId
|
||||||
|
|
|
@ -132,7 +132,7 @@ class RoomListSectionBuilderSpace(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
appStateHandler.selectedRoomGroupingObservable
|
appStateHandler.selectedRoomGroupingFlow
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.onEach { groupingMethod ->
|
.onEach { groupingMethod ->
|
||||||
val selectedSpace = groupingMethod.orNull()?.space()
|
val selectedSpace = groupingMethod.orNull()?.space()
|
||||||
|
@ -222,7 +222,7 @@ class RoomListSectionBuilderSpace(
|
||||||
|
|
||||||
// add suggested rooms
|
// add suggested rooms
|
||||||
val suggestedRoomsFlow = // MutableLiveData<List<SpaceChildInfo>>()
|
val suggestedRoomsFlow = // MutableLiveData<List<SpaceChildInfo>>()
|
||||||
appStateHandler.selectedRoomGroupingObservable
|
appStateHandler.selectedRoomGroupingFlow
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.flatMapLatest { groupingMethod ->
|
.flatMapLatest { groupingMethod ->
|
||||||
val selectedSpace = groupingMethod.orNull()?.space()
|
val selectedSpace = groupingMethod.orNull()?.space()
|
||||||
|
|
|
@ -92,7 +92,7 @@ class RoomListViewModel @AssistedInject constructor(
|
||||||
init {
|
init {
|
||||||
observeMembershipChanges()
|
observeMembershipChanges()
|
||||||
|
|
||||||
appStateHandler.selectedRoomGroupingObservable
|
appStateHandler.selectedRoomGroupingFlow
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.execute {
|
.execute {
|
||||||
copy(
|
copy(
|
||||||
|
|
|
@ -88,7 +88,7 @@ class SpaceListViewModel @AssistedInject constructor(@Assisted initialState: Spa
|
||||||
|
|
||||||
observeSpaceSummaries()
|
observeSpaceSummaries()
|
||||||
// observeSelectionState()
|
// observeSelectionState()
|
||||||
appStateHandler.selectedRoomGroupingObservable
|
appStateHandler.selectedRoomGroupingFlow
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.setOnEach {
|
.setOnEach {
|
||||||
copy(
|
copy(
|
||||||
|
|
Loading…
Reference in a new issue