Renaming observe item count method

This commit is contained in:
Maxime Naturel 2022-02-17 17:21:46 +01:00
parent 291d7d7627
commit a826a50c10
1 changed files with 4 additions and 5 deletions

View File

@ -52,7 +52,6 @@ import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedA
import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel
import im.vector.app.features.home.room.list.widget.NotifsFabMenuView import im.vector.app.features.home.room.list.widget.NotifsFabMenuView
import im.vector.app.features.notifications.NotificationDrawerManager import im.vector.app.features.notifications.NotificationDrawerManager
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -291,7 +290,7 @@ class RoomListFragment @Inject constructor(
)) ))
checkEmptyState() checkEmptyState()
} }
listenItemCount(section, sectionAdapter) observeItemCount(section, sectionAdapter)
section.notificationCount.observe(viewLifecycleOwner) { counts -> section.notificationCount.observe(viewLifecycleOwner) { counts ->
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy( sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
notificationCount = counts.totalCount, notificationCount = counts.totalCount,
@ -315,7 +314,7 @@ class RoomListFragment @Inject constructor(
)) ))
checkEmptyState() checkEmptyState()
} }
listenItemCount(section, sectionAdapter) observeItemCount(section, sectionAdapter)
section.isExpanded.observe(viewLifecycleOwner) { _ -> section.isExpanded.observe(viewLifecycleOwner) { _ ->
refreshCollapseStates() refreshCollapseStates()
} }
@ -332,7 +331,7 @@ class RoomListFragment @Inject constructor(
isLoading = false)) isLoading = false))
checkEmptyState() checkEmptyState()
} }
listenItemCount(section, sectionAdapter) observeItemCount(section, sectionAdapter)
section.notificationCount.observe(viewLifecycleOwner) { counts -> section.notificationCount.observe(viewLifecycleOwner) { counts ->
sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy( sectionAdapter.updateSection(sectionAdapter.roomsSectionData.copy(
notificationCount = counts.totalCount, notificationCount = counts.totalCount,
@ -380,7 +379,7 @@ class RoomListFragment @Inject constructor(
} }
} }
private fun listenItemCount(section: RoomsSection, sectionAdapter: SectionHeaderAdapter) { private fun observeItemCount(section: RoomsSection, sectionAdapter: SectionHeaderAdapter) {
lifecycleScope.launch { lifecycleScope.launch {
section.itemCount section.itemCount
.flowWithLifecycle(lifecycle, Lifecycle.State.STARTED) .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED)