Fix some issues from 7ff95e2 (#415)

* Fixed extra header introduced in 7ff95e2

* Removed parentheses to make detekt happy

* Updated relative date display for dates in the future

* Small cleanup for header creation logic

* replaced "and" with "&&" for better formatting
This commit is contained in:
Maddie Witman
2024-02-24 14:33:46 -05:00
committed by GitHub
parent ab02568ac6
commit 07f963d5ae
4 changed files with 20 additions and 13 deletions
@@ -45,7 +45,6 @@ import tachiyomi.domain.updates.interactor.GetUpdates
import tachiyomi.domain.updates.model.UpdatesWithRelations
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.time.LocalDate
import java.time.ZonedDateTime
class UpdatesScreenModel(
@@ -374,12 +373,10 @@ class UpdatesScreenModel(
return items
.map { UpdatesUiModel.Item(it) }
.insertSeparators { before, after ->
val beforeDate = before?.item?.update?.dateFetch?.toLocalDate() ?: LocalDate.MIN
val afterDate = after?.item?.update?.dateFetch?.toLocalDate() ?: LocalDate.MIN
val beforeDate = before?.item?.update?.dateFetch?.toLocalDate()
val afterDate = after?.item?.update?.dateFetch?.toLocalDate()
when {
beforeDate.isAfter(afterDate)
or afterDate.equals(LocalDate.MIN)
or beforeDate.equals(LocalDate.MIN) -> UpdatesUiModel.Header(afterDate)
beforeDate != afterDate && afterDate != null -> UpdatesUiModel.Header(afterDate)
// Return null to avoid adding a separator between two items.
else -> null
}