From 632318311945a8a35a6473a14b361da4c23a9d2f Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 10 Jun 2019 17:06:58 +0200 Subject: [PATCH] Ganfra's review: use sumBy() instead of reduce() --- .../vector/riotredesign/features/home/HomeDetailViewModel.kt | 4 ++-- .../features/home/room/list/RoomSummaryController.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/HomeDetailViewModel.kt b/vector/src/main/java/im/vector/riotredesign/features/home/HomeDetailViewModel.kt index 9e36dfc162..81a8f790fa 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/HomeDetailViewModel.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/HomeDetailViewModel.kt @@ -52,7 +52,7 @@ class HomeDetailViewModel(initialState: HomeDetailViewState, .filter { it.isDirect } .map { it.notificationCount } .takeIf { it.isNotEmpty() } - ?.reduce { acc, i -> acc + i } + ?.sumBy { i -> i } ?: 0 val peopleHasHighlight = summaries .filter { it.isDirect } @@ -62,7 +62,7 @@ class HomeDetailViewModel(initialState: HomeDetailViewState, .filter { !it.isDirect } .map { it.notificationCount } .takeIf { it.isNotEmpty() } - ?.reduce { acc, i -> acc + i } + ?.sumBy { i -> i } ?: 0 val roomsHasHighlight = summaries .filter { !it.isDirect } diff --git a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomSummaryController.kt b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomSummaryController.kt index 9d8e555f07..eafcb7dd4e 100644 --- a/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomSummaryController.kt +++ b/vector/src/main/java/im/vector/riotredesign/features/home/room/list/RoomSummaryController.kt @@ -64,7 +64,7 @@ class RoomSummaryController(private val stringProvider: StringProvider, val unreadCount = if (summaries.isEmpty()) { 0 } else { - summaries.map { it.notificationCount }.reduce { acc, i -> acc + i } + summaries.map { it.notificationCount }.sumBy { i -> i } } val showHighlighted = summaries.any { it.highlightCount > 0 } roomCategoryItem {