mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 05:31:21 +03:00
Ganfra's review: use sumBy() instead of reduce()
This commit is contained in:
parent
3439a9ca27
commit
6323183119
2 changed files with 3 additions and 3 deletions
|
@ -52,7 +52,7 @@ class HomeDetailViewModel(initialState: HomeDetailViewState,
|
||||||
.filter { it.isDirect }
|
.filter { it.isDirect }
|
||||||
.map { it.notificationCount }
|
.map { it.notificationCount }
|
||||||
.takeIf { it.isNotEmpty() }
|
.takeIf { it.isNotEmpty() }
|
||||||
?.reduce { acc, i -> acc + i }
|
?.sumBy { i -> i }
|
||||||
?: 0
|
?: 0
|
||||||
val peopleHasHighlight = summaries
|
val peopleHasHighlight = summaries
|
||||||
.filter { it.isDirect }
|
.filter { it.isDirect }
|
||||||
|
@ -62,7 +62,7 @@ class HomeDetailViewModel(initialState: HomeDetailViewState,
|
||||||
.filter { !it.isDirect }
|
.filter { !it.isDirect }
|
||||||
.map { it.notificationCount }
|
.map { it.notificationCount }
|
||||||
.takeIf { it.isNotEmpty() }
|
.takeIf { it.isNotEmpty() }
|
||||||
?.reduce { acc, i -> acc + i }
|
?.sumBy { i -> i }
|
||||||
?: 0
|
?: 0
|
||||||
val roomsHasHighlight = summaries
|
val roomsHasHighlight = summaries
|
||||||
.filter { !it.isDirect }
|
.filter { !it.isDirect }
|
||||||
|
|
|
@ -64,7 +64,7 @@ class RoomSummaryController(private val stringProvider: StringProvider,
|
||||||
val unreadCount = if (summaries.isEmpty()) {
|
val unreadCount = if (summaries.isEmpty()) {
|
||||||
0
|
0
|
||||||
} else {
|
} else {
|
||||||
summaries.map { it.notificationCount }.reduce { acc, i -> acc + i }
|
summaries.map { it.notificationCount }.sumBy { i -> i }
|
||||||
}
|
}
|
||||||
val showHighlighted = summaries.any { it.highlightCount > 0 }
|
val showHighlighted = summaries.any { it.highlightCount > 0 }
|
||||||
roomCategoryItem {
|
roomCategoryItem {
|
||||||
|
|
Loading…
Reference in a new issue