diff --git a/vector/src/main/java/im/vector/app/AppStateHandler.kt b/vector/src/main/java/im/vector/app/AppStateHandler.kt index b38ae10ad0..57da0f4e24 100644 --- a/vector/src/main/java/im/vector/app/AppStateHandler.kt +++ b/vector/src/main/java/im/vector/app/AppStateHandler.kt @@ -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) + } } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt index f53c657856..31b735dbcd 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeDetailFragment.kt @@ -274,6 +274,13 @@ class HomeDetailFragment @Inject constructor( } } + override fun onPause() { + super.onPause() + + // Persist swiped + appStateHandler.persistSelectedSpace() + } + private fun checkNotificationTabStatus(enableDialPad: Boolean? = null) { val wasVisible = views.bottomNavigationView.menu.findItem(R.id.bottom_action_notification).isVisible val combinedOverview = vectorPreferences.combinedOverview()