From cd6fab0e2d35a0a5d92f563acf35188bea84aaa8 Mon Sep 17 00:00:00 2001
From: Valere <valeref@matrix.org>
Date: Wed, 31 Mar 2021 17:36:24 +0200
Subject: [PATCH] Fix empty state + cleaning + changelog

---
 CHANGES.md                                                      | 1 +
 .../im/vector/app/features/home/room/list/RoomListFragment.kt   | 2 +-
 .../vector/app/features/home/room/list/SectionHeaderAdapter.kt  | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/CHANGES.md b/CHANGES.md
index ed549c918f..45b3905375 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -14,6 +14,7 @@ Improvements 🙌:
  - Update reactions to Unicode 13.1 (#2998)
  - Be more robust when parsing some enums
  - Improve timeline filtering (dissociate membership and profile events, display hidden events when highlighted, fix hidden item/read receipts behavior)
+ - Room list improvements (paging)
 
 Bugfix 🐛:
  - Fix bad theme change for the MainActivity
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 ac59283e7a..cf74cae37c 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
@@ -249,7 +249,7 @@ class RoomListFragment @Inject constructor(
             val contentAdapter = pagedControllerFactory.createRoomSummaryPagedController().also {
                 section.livePages.observe(viewLifecycleOwner) { pl ->
                     it.submitList(pl)
-                    sectionAdapter.updateSection(sectionAdapter.section.copy(isHidden = pl.isEmpty() || hasOnlyOneSection))
+                    sectionAdapter.updateSection(sectionAdapter.section.copy(isHidden = pl.isEmpty()))
                     checkEmptyState()
                 }
                 section.notificationCount.observe(viewLifecycleOwner) { counts ->
diff --git a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt
index 30f0e671f9..b137947ef7 100644
--- a/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt
+++ b/vector/src/main/java/im/vector/app/features/home/room/list/SectionHeaderAdapter.kt
@@ -64,7 +64,7 @@ class SectionHeaderAdapter constructor(
         holder.bind(section)
     }
 
-    override fun getItemCount(): Int = 1.takeIf { section.isHidden.not() } ?: 0
+    override fun getItemCount(): Int = if (section.isHidden) 0 else 1
 
     class VH constructor(
             private val binding: ItemRoomCategoryBinding,