Persist selected space on home fragment pause

Change-Id: Ib7771d83c0adb7a9e228261a55bac2f1de0f118f
This commit is contained in:
SpiritCroc 2022-03-31 10:46:38 +02:00
parent ca31577858
commit 36c290f112
2 changed files with 22 additions and 0 deletions

View file

@ -164,4 +164,19 @@ class AppStateHandler @Inject constructor(
} }
} }
} }
fun persistSelectedSpace() {
val currentValue = selectedSpaceDataSourceSc.currentValue?.orNull() ?: return
val currentMethod = currentValue.first as? RoomGroupingMethod.BySpace ?: return
val uSession = activeSessionHolder.getSafeActiveSession() ?: return
// We want to persist it, so we also want to remove the pendingSwipe status
if (currentValue.second) {
selectedSpaceDataSourceSc.post(Option.just(Pair(currentMethod, false)))
}
// Persist it across app restarts
uiStateRepository.storeGroupingMethod(true, uSession.sessionId)
uiStateRepository.storeSelectedSpace(currentMethod.spaceSummary?.roomId, uSession.sessionId)
}
} }

View file

@ -274,6 +274,13 @@ class HomeDetailFragment @Inject constructor(
} }
} }
override fun onPause() {
super.onPause()
// Persist swiped
appStateHandler.persistSelectedSpace()
}
private fun checkNotificationTabStatus(enableDialPad: Boolean? = null) { private fun checkNotificationTabStatus(enableDialPad: Boolean? = null) {
val wasVisible = views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible val wasVisible = views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible
val combinedOverview = vectorPreferences.combinedOverview() val combinedOverview = vectorPreferences.combinedOverview()