From a6e76802129d36f6b77382bea9a77d145ac53533 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Thu, 9 May 2019 17:38:13 +0200 Subject: [PATCH] Fixed logs being bugged down by unreliable code --- .../magisk/data/repository/LogRepository.kt | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt b/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt index a07c7f7ba..caf60174a 100644 --- a/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt +++ b/app/src/main/java/com/topjohnwu/magisk/data/repository/LogRepository.kt @@ -33,22 +33,8 @@ class LogRepository( private fun List.wrap(): List { val day = TimeUnit.DAYS.toMillis(1) - var currentDay = firstOrNull()?.date?.time ?: return listOf() - var tempList = this - val outList = mutableListOf() - - while (tempList.isNotEmpty()) { - val logsGivenDay = takeWhile { it.date.time / day == currentDay / day } - currentDay = tempList.firstOrNull()?.date?.time ?: currentDay + day - - if (logsGivenDay.isEmpty()) - continue - - outList.add(WrappedMagiskLog(currentDay / day * day, logsGivenDay)) - tempList = tempList.subList(logsGivenDay.size, tempList.size) - } - - return outList + return groupBy { it.date.time / day } + .map { WrappedMagiskLog(it.key * day, it.value) } }