Fixed "0 mins ago" in "Library last updated" string (#8279)
* Fixed "0 mins ago" in "Library last updated" string * Recommended fixes
This commit is contained in:
parent
5c868d7846
commit
f30150c0f0
2 changed files with 14 additions and 3 deletions
|
@ -48,13 +48,19 @@ import eu.kanade.tachiyomi.data.download.model.Download
|
||||||
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem
|
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesItem
|
||||||
import java.text.DateFormat
|
import java.text.DateFormat
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
|
import kotlin.time.Duration.Companion.minutes
|
||||||
|
|
||||||
fun LazyListScope.updatesLastUpdatedItem(
|
fun LazyListScope.updatesLastUpdatedItem(
|
||||||
lastUpdated: Long,
|
lastUpdated: Long,
|
||||||
) {
|
) {
|
||||||
item(key = "updates-lastUpdated") {
|
item(key = "updates-lastUpdated") {
|
||||||
val time = remember(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(
|
Box(
|
||||||
|
@ -63,7 +69,11 @@ fun LazyListScope.updatesLastUpdatedItem(
|
||||||
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
.padding(horizontal = horizontalPadding, vertical = 8.dp),
|
||||||
) {
|
) {
|
||||||
Text(
|
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(
|
style = LocalTextStyle.current.copy(
|
||||||
fontStyle = FontStyle.Italic,
|
fontStyle = FontStyle.Italic,
|
||||||
),
|
),
|
||||||
|
|
|
@ -750,7 +750,8 @@
|
||||||
<string name="updating_library">Updating library</string>
|
<string name="updating_library">Updating library</string>
|
||||||
<string name="update_already_running">An update is already running</string>
|
<string name="update_already_running">An update is already running</string>
|
||||||
<string name="cant_open_last_read_chapter">Unable to open last read chapter</string>
|
<string name="cant_open_last_read_chapter">Unable to open last read chapter</string>
|
||||||
<string name="updates_last_update_info">Library last updated: %1$s</string>
|
<string name="updates_last_update_info">Library last updated: %s</string>
|
||||||
|
<string name="updates_last_update_info_just_now">Just now</string>
|
||||||
|
|
||||||
<!-- History fragment -->
|
<!-- History fragment -->
|
||||||
<string name="recent_manga_time">Ch. %1$s - %2$s</string>
|
<string name="recent_manga_time">Ch. %1$s - %2$s</string>
|
||||||
|
|
Reference in a new issue