Hide unimportant unreads counter when spaces bottom bar is visible
Change-Id: I54df339e53877e334a6a2b463916017cb5ccbc30
This commit is contained in:
parent
43d77f553e
commit
a53c183847
|
@ -241,16 +241,15 @@ class HomeDetailFragment :
|
|||
}
|
||||
|
||||
unreadMessagesSharedViewModel.onEach { state ->
|
||||
views.drawerUnreadCounterBadgeView.render(
|
||||
val count =
|
||||
UnreadCounterBadgeView.State.Count(
|
||||
count = state.otherSpacesUnread.totalCount,
|
||||
highlighted = state.otherSpacesUnread.isHighlight,
|
||||
unread = state.otherSpacesUnread.unreadCount,
|
||||
markedUnread = false
|
||||
).also {
|
||||
spaceBarController.submitHomeUnreadCounts(it)
|
||||
}
|
||||
)
|
||||
spaceBarController.submitHomeUnreadCounts(count)
|
||||
renderDrawerUnreads(count)
|
||||
}
|
||||
|
||||
viewModel.onEach(HomeDetailViewState::selectedSpaceIgnoreSwipe,
|
||||
|
@ -274,6 +273,15 @@ class HomeDetailFragment :
|
|||
}
|
||||
}
|
||||
|
||||
private fun renderDrawerUnreads(count: UnreadCounterBadgeView.State.Count) {
|
||||
if (pagerPagingEnabled) {
|
||||
// Bottom bar shows unread counts already, so remove unnecessary noise
|
||||
views.drawerUnreadCounterBadgeView.render(count.copy(unread = 0))
|
||||
} else {
|
||||
views.drawerUnreadCounterBadgeView.render(count)
|
||||
}
|
||||
}
|
||||
|
||||
private fun selectSpaceFromSwipe(position: Int) {
|
||||
val selectedId = getSpaceIdForPageIndex(position)
|
||||
spaceStateHandler.setCurrentSpace(selectedId, from = SelectSpaceFrom.SWIPE)
|
||||
|
@ -645,7 +653,20 @@ class HomeDetailFragment :
|
|||
spaceStateHandler.persistSelectedSpace()
|
||||
pagerSpaces = safeSpaces
|
||||
pagerTab = tab
|
||||
if (pagerPagingEnabled != pagingEnabled) {
|
||||
pagerPagingEnabled = pagingEnabled
|
||||
// Update counts which depend on pagerPagingEnabled
|
||||
withState(unreadMessagesSharedViewModel) { state ->
|
||||
renderDrawerUnreads(
|
||||
UnreadCounterBadgeView.State.Count(
|
||||
count = state.otherSpacesUnread.totalCount,
|
||||
highlighted = state.otherSpacesUnread.isHighlight,
|
||||
unread = state.otherSpacesUnread.unreadCount,
|
||||
markedUnread = false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
initialPageSelected = false
|
||||
|
||||
// OFFSCREEN_PAGE_LIMIT_DEFAULT: default recyclerview caching mechanism instead of explicit fixed prefetching
|
||||
|
|
Loading…
Reference in New Issue