Adds working back navigation
This commit is contained in:
parent
894d4f700e
commit
06baae04ed
|
@ -85,8 +85,6 @@ class SpaceStateHandlerImpl @Inject constructor(
|
||||||
|
|
||||||
if (isForwardNavigation) {
|
if (isForwardNavigation) {
|
||||||
addToBackstacks(spaceToLeave, spaceToSet)
|
addToBackstacks(spaceToLeave, spaceToSet)
|
||||||
} else {
|
|
||||||
popBackstackUntil(spaceToSet)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (persistNow) {
|
if (persistNow) {
|
||||||
|
@ -121,19 +119,6 @@ class SpaceStateHandlerImpl @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun popBackstackUntil(space: RoomSummary?) {
|
|
||||||
val spaceId = space?.roomId
|
|
||||||
while (spaceBackstack.last() != spaceId) {
|
|
||||||
spaceBackstack.removeLast()
|
|
||||||
}
|
|
||||||
|
|
||||||
val currentPersistedBackstack = vectorPreferences.getPersistedSpaceBackstack().toMutableList()
|
|
||||||
while (currentPersistedBackstack.last() != spaceId) {
|
|
||||||
currentPersistedBackstack.removeLast()
|
|
||||||
}
|
|
||||||
vectorPreferences.setPersistedSpaceBackstack(currentPersistedBackstack)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun observeActiveSession() {
|
private fun observeActiveSession() {
|
||||||
sessionDataSource.stream()
|
sessionDataSource.stream()
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
|
@ -160,7 +145,7 @@ class SpaceStateHandlerImpl @Inject constructor(
|
||||||
override fun popSpaceBackstack(): String? {
|
override fun popSpaceBackstack(): String? {
|
||||||
val poppedSpaceId = spaceBackstack.removeLast()
|
val poppedSpaceId = spaceBackstack.removeLast()
|
||||||
vectorPreferences.getPersistedSpaceBackstack().toMutableList().apply {
|
vectorPreferences.getPersistedSpaceBackstack().toMutableList().apply {
|
||||||
removeLast()
|
removeLastOrNull()
|
||||||
vectorPreferences.setPersistedSpaceBackstack(this)
|
vectorPreferences.setPersistedSpaceBackstack(this)
|
||||||
}
|
}
|
||||||
return poppedSpaceId
|
return poppedSpaceId
|
||||||
|
|
|
@ -79,7 +79,6 @@ class NewHomeDetailFragment @Inject constructor(
|
||||||
|
|
||||||
private val viewModel: HomeDetailViewModel by fragmentViewModel()
|
private val viewModel: HomeDetailViewModel by fragmentViewModel()
|
||||||
private val unknownDeviceDetectorSharedViewModel: UnknownDeviceDetectorSharedViewModel by activityViewModel()
|
private val unknownDeviceDetectorSharedViewModel: UnknownDeviceDetectorSharedViewModel by activityViewModel()
|
||||||
private val unreadMessagesSharedViewModel: UnreadMessagesSharedViewModel by activityViewModel()
|
|
||||||
private val serverBackupStatusViewModel: ServerBackupStatusViewModel by activityViewModel()
|
private val serverBackupStatusViewModel: ServerBackupStatusViewModel by activityViewModel()
|
||||||
|
|
||||||
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
|
private lateinit var sharedActionViewModel: HomeSharedActionViewModel
|
||||||
|
@ -177,19 +176,6 @@ class NewHomeDetailFragment @Inject constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun navigateBack() {
|
|
||||||
try {
|
|
||||||
val previousSpaceId = spaceStateHandler.popSpaceBackstack()
|
|
||||||
setCurrentSpace(previousSpaceId)
|
|
||||||
} catch (e: NoSuchElementException) {
|
|
||||||
requireActivity().finish()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun setCurrentSpace(spaceId: String?) {
|
|
||||||
spaceStateHandler.setCurrentSpace(spaceId, isForwardNavigation = false)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun handleCallStarted() {
|
private fun handleCallStarted() {
|
||||||
dismissLoadingDialog()
|
dismissLoadingDialog()
|
||||||
val fragmentTag = HomeTab.DialPad.toFragmentTag()
|
val fragmentTag = HomeTab.DialPad.toFragmentTag()
|
||||||
|
@ -454,8 +440,11 @@ class NewHomeDetailFragment @Inject constructor(
|
||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed(toolbarButton: Boolean): Boolean {
|
override fun onBackPressed(toolbarButton: Boolean) = try {
|
||||||
navigateBack()
|
val lastSpace = spaceStateHandler.popSpaceBackstack()
|
||||||
return true
|
spaceStateHandler.setCurrentSpace(lastSpace, isForwardNavigation = false)
|
||||||
|
true
|
||||||
|
} catch (e: NoSuchElementException) {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue