From c258644ae26cd5ff578d043b7117974650d73027 Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Tue, 13 Dec 2022 15:47:55 -0500 Subject: [PATCH] Fix crash when using .max function --- .../main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt index b547ec30..0a89c038 100644 --- a/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt +++ b/presentation/src/main/java/com/moez/QKSMS/feature/backup/BackupPresenter.kt @@ -64,7 +64,7 @@ class BackupPresenter @Inject constructor( .distinctUntilChanged() .switchMap { backupRepo.getBackups() } .doOnNext { backups -> newState { copy(backups = backups) } } - .map { backups -> backups.map { it.date }.max() ?: 0L } + .map { backups -> backups.maxOfOrNull { it.date } ?: 0L } .map { lastBackup -> when (lastBackup) { 0L -> context.getString(R.string.backup_never)