RoomListFragment: Use proper way to observe space changes
Change-Id: I30d65c3e653eb82f4095ed538aec9a4c8c2de337
This commit is contained in:
parent
31c01c98de
commit
cd1449d9bb
@ -63,8 +63,6 @@ class AppStateHandler @Inject constructor(
|
|||||||
|
|
||||||
val selectedRoomGroupingFlow = selectedSpaceDataSource.stream()
|
val selectedRoomGroupingFlow = selectedSpaceDataSource.stream()
|
||||||
|
|
||||||
var onSwitchSpaceListener: OnSwitchSpaceListener? = null
|
|
||||||
|
|
||||||
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
|
||||||
// For example just after creating a space and switching to it the
|
// For example just after creating a space and switching to it the
|
||||||
@ -99,7 +97,6 @@ class AppStateHandler @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onSwitchSpaceListener?.onSwitchSpace(spaceId)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCurrentGroup(groupId: String?, session: Session? = null) {
|
fun setCurrentGroup(groupId: String?, session: Session? = null) {
|
||||||
@ -159,8 +156,4 @@ class AppStateHandler @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OnSwitchSpaceListener {
|
|
||||||
fun onSwitchSpace(spaceId: String?)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedA
|
|||||||
import im.vector.app.features.home.room.list.widget.NotifsFabMenuView
|
import im.vector.app.features.home.room.list.widget.NotifsFabMenuView
|
||||||
import im.vector.app.features.notifications.NotificationDrawerManager
|
import im.vector.app.features.notifications.NotificationDrawerManager
|
||||||
import im.vector.app.features.settings.VectorPreferences
|
import im.vector.app.features.settings.VectorPreferences
|
||||||
|
import im.vector.app.space
|
||||||
import kotlinx.coroutines.flow.launchIn
|
import kotlinx.coroutines.flow.launchIn
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import kotlinx.parcelize.Parcelize
|
import kotlinx.parcelize.Parcelize
|
||||||
@ -81,7 +82,6 @@ class RoomListFragment @Inject constructor(
|
|||||||
) : VectorBaseFragment<FragmentRoomListBinding>(),
|
) : VectorBaseFragment<FragmentRoomListBinding>(),
|
||||||
RoomListListener,
|
RoomListListener,
|
||||||
OnBackPressed,
|
OnBackPressed,
|
||||||
AppStateHandler.OnSwitchSpaceListener,
|
|
||||||
FilteredRoomFooterItem.Listener,
|
FilteredRoomFooterItem.Listener,
|
||||||
NotifsFabMenuView.Listener {
|
NotifsFabMenuView.Listener {
|
||||||
|
|
||||||
@ -157,7 +157,10 @@ class RoomListFragment @Inject constructor(
|
|||||||
(it.contentEpoxyController as? RoomSummaryPagedController)?.roomChangeMembershipStates = ms
|
(it.contentEpoxyController as? RoomSummaryPagedController)?.roomChangeMembershipStates = ms
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
appStateHandler.onSwitchSpaceListener = this
|
roomListViewModel.onEach(RoomListViewState::currentRoomGrouping) {
|
||||||
|
val spaceId = it.invoke()?.space()?.roomId
|
||||||
|
onSwitchSpace(spaceId)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -574,7 +577,7 @@ class RoomListFragment @Inject constructor(
|
|||||||
const val ROOM_LIST_ROOM_EXPANDED_ANY_PREFIX = "ROOM_LIST_ROOM_EXPANDED"
|
const val ROOM_LIST_ROOM_EXPANDED_ANY_PREFIX = "ROOM_LIST_ROOM_EXPANDED"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSwitchSpace(spaceId: String?) {
|
private fun onSwitchSpace(spaceId: String?) {
|
||||||
if (roomListParams.explicitSpaceId == SPACE_ID_FOLLOW_APP) {
|
if (roomListParams.explicitSpaceId == SPACE_ID_FOLLOW_APP) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user