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 ->
|
unreadMessagesSharedViewModel.onEach { state ->
|
||||||
views.drawerUnreadCounterBadgeView.render(
|
val count =
|
||||||
UnreadCounterBadgeView.State.Count(
|
UnreadCounterBadgeView.State.Count(
|
||||||
count = state.otherSpacesUnread.totalCount,
|
count = state.otherSpacesUnread.totalCount,
|
||||||
highlighted = state.otherSpacesUnread.isHighlight,
|
highlighted = state.otherSpacesUnread.isHighlight,
|
||||||
unread = state.otherSpacesUnread.unreadCount,
|
unread = state.otherSpacesUnread.unreadCount,
|
||||||
markedUnread = false
|
markedUnread = false
|
||||||
).also {
|
|
||||||
spaceBarController.submitHomeUnreadCounts(it)
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
spaceBarController.submitHomeUnreadCounts(count)
|
||||||
|
renderDrawerUnreads(count)
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.onEach(HomeDetailViewState::selectedSpaceIgnoreSwipe,
|
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) {
|
private fun selectSpaceFromSwipe(position: Int) {
|
||||||
val selectedId = getSpaceIdForPageIndex(position)
|
val selectedId = getSpaceIdForPageIndex(position)
|
||||||
spaceStateHandler.setCurrentSpace(selectedId, from = SelectSpaceFrom.SWIPE)
|
spaceStateHandler.setCurrentSpace(selectedId, from = SelectSpaceFrom.SWIPE)
|
||||||
|
@ -645,7 +653,20 @@ class HomeDetailFragment :
|
||||||
spaceStateHandler.persistSelectedSpace()
|
spaceStateHandler.persistSelectedSpace()
|
||||||
pagerSpaces = safeSpaces
|
pagerSpaces = safeSpaces
|
||||||
pagerTab = tab
|
pagerTab = tab
|
||||||
|
if (pagerPagingEnabled != pagingEnabled) {
|
||||||
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
|
initialPageSelected = false
|
||||||
|
|
||||||
// OFFSCREEN_PAGE_LIMIT_DEFAULT: default recyclerview caching mechanism instead of explicit fixed prefetching
|
// OFFSCREEN_PAGE_LIMIT_DEFAULT: default recyclerview caching mechanism instead of explicit fixed prefetching
|
||||||
|
|
Loading…
Reference in New Issue