From f30150c0f08e89cdd240520f77f0bd547a0de4f6 Mon Sep 17 00:00:00 2001 From: Dexroneum <46288465+Dexroneum@users.noreply.github.com> Date: Sun, 23 Oct 2022 00:59:07 +0100 Subject: [PATCH] Fixed "0 mins ago" in "Library last updated" string (#8279) * Fixed "0 mins ago" in "Library last updated" string * Recommended fixes --- .../kanade/presentation/updates/UpdatesUiItem.kt | 14 ++++++++++++-- i18n/src/main/res/values/strings.xml | 3 ++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt index 3c60420e3..8e56b9f80 100644 --- a/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt +++ b/app/src/main/java/eu/kanade/presentation/updates/UpdatesUiItem.kt @@ -48,13 +48,19 @@ import eu.kanade.tachiyomi.data.download.model.Download import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem import java.text.DateFormat import java.util.Date +import kotlin.time.Duration.Companion.minutes fun LazyListScope.updatesLastUpdatedItem( lastUpdated: Long, ) { item(key = "updates-lastUpdated") { val time = remember(lastUpdated) { - DateUtils.getRelativeTimeSpanString(lastUpdated, Date().time, DateUtils.MINUTE_IN_MILLIS) + val now = Date().time + if (now - lastUpdated < 1.minutes.inWholeMilliseconds) { + null + } else { + DateUtils.getRelativeTimeSpanString(lastUpdated, now, DateUtils.MINUTE_IN_MILLIS) + } } Box( @@ -63,7 +69,11 @@ fun LazyListScope.updatesLastUpdatedItem( .padding(horizontal = horizontalPadding, vertical = 8.dp), ) { Text( - text = stringResource(R.string.updates_last_update_info, time), + text = if (time.isNullOrEmpty()) { + stringResource(R.string.updates_last_update_info, stringResource(R.string.updates_last_update_info_just_now)) + } else { + stringResource(R.string.updates_last_update_info, time) + }, style = LocalTextStyle.current.copy( fontStyle = FontStyle.Italic, ), diff --git a/i18n/src/main/res/values/strings.xml b/i18n/src/main/res/values/strings.xml index 2783ef910..b7c8da831 100644 --- a/i18n/src/main/res/values/strings.xml +++ b/i18n/src/main/res/values/strings.xml @@ -750,7 +750,8 @@ Updating library An update is already running Unable to open last read chapter - Library last updated: %1$s + Library last updated: %s + Just now Ch. %1$s - %2$s