From 2d710923a1e891dab4f81e808af0024c6b163809 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Wed, 12 Oct 2022 18:56:39 +0200 Subject: [PATCH] Fix persisting room sections Change-Id: Ia39e84c00bad8777605c237534cb6f13f5741fe0 --- .../app/features/home/room/list/RoomListFragment.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt index 2796f5fe43..805e6c79de 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/list/RoomListFragment.kt @@ -101,6 +101,7 @@ class RoomListFragment : private lateinit var stateRestorer: LayoutManagerStateRestorer private var expandStatusSpaceId: String? = null + private var lastLoadForcedExpand: Boolean = false val dbgId = System.identityHashCode(this) private val viewPagerDimber = Dimber("Home pager rlf/$dbgId", DbgUtil.DBG_VIEW_PAGER) @@ -240,9 +241,13 @@ class RoomListFragment : private fun refreshCollapseStates() { val sectionsCount = adapterInfosList.count { !it.sectionHeaderAdapter.roomsSectionData.isHidden } + val isRoomSectionCollapsable = sectionsCount > 1 + if (lastLoadForcedExpand && isRoomSectionCollapsable) { + loadExpandStatus() + } + lastLoadForcedExpand = !isRoomSectionCollapsable roomListViewModel.sections.forEachIndexed { index, roomsSection -> val actualBlock = adapterInfosList[index] - val isRoomSectionCollapsable = sectionsCount > 1 val isRoomSectionExpanded = roomsSection.isExpanded.value.orTrue() if (actualBlock.section.isExpanded && !isRoomSectionExpanded) { // mark controller as collapsed @@ -705,6 +710,8 @@ class RoomListFragment : } private fun persistExpandStatus() { + // No need to persist force-expanded values + if (lastLoadForcedExpand) return val spEdit = getSharedPreferences()?.edit() ?: return roomListViewModel.sections.forEach{section -> val isExpanded = section.isExpanded.value