Skip to content

Commit

Permalink
fix: Group updates by date and not time
Browse files Browse the repository at this point in the history
  • Loading branch information
jmir1 committed Jul 18, 2024
1 parent 291c24b commit c83ebf3
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import tachiyomi.presentation.core.screens.EmptyScreen
import tachiyomi.presentation.core.screens.LoadingScreen
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
import java.time.LocalDateTime
import java.time.LocalDate
import kotlin.time.Duration.Companion.seconds

@Composable
Expand Down Expand Up @@ -153,6 +153,6 @@ private fun AnimeUpdatesBottomBar(
}

sealed interface AnimeUpdatesUiModel {
data class Header(val date: LocalDateTime) : AnimeUpdatesUiModel
data class Header(val date: LocalDate) : AnimeUpdatesUiModel
data class Item(val item: AnimeUpdatesItem) : AnimeUpdatesUiModel
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.components.relativeDateTimeText
import eu.kanade.presentation.components.relativeDateText
import eu.kanade.presentation.entries.anime.components.EpisodeDownloadAction
import eu.kanade.presentation.entries.anime.components.EpisodeDownloadIndicator
import eu.kanade.presentation.entries.components.DotSeparatorText
Expand Down Expand Up @@ -96,7 +96,7 @@ internal fun LazyListScope.animeUpdatesUiItems(
is AnimeUpdatesUiModel.Header -> {
ListGroupHeader(
modifier = Modifier.animateItem(),
text = relativeDateTimeText(item.date),
text = relativeDateText(item.date),
)
}
is AnimeUpdatesUiModel.Item -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import tachiyomi.presentation.core.components.material.PullRefresh
import tachiyomi.presentation.core.components.material.Scaffold
import tachiyomi.presentation.core.screens.EmptyScreen
import tachiyomi.presentation.core.screens.LoadingScreen
import java.time.LocalDateTime
import java.time.LocalDate
import kotlin.time.Duration.Companion.seconds

@Composable
Expand Down Expand Up @@ -141,6 +141,6 @@ private fun MangaUpdatesBottomBar(
}

sealed interface MangaUpdatesUiModel {
data class Header(val date: LocalDateTime) : MangaUpdatesUiModel
data class Header(val date: LocalDate) : MangaUpdatesUiModel
data class Item(val item: MangaUpdatesItem) : MangaUpdatesUiModel
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import androidx.compose.ui.platform.LocalHapticFeedback
import androidx.compose.ui.text.font.FontStyle
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import eu.kanade.presentation.components.relativeDateTimeText
import eu.kanade.presentation.components.relativeDateText
import eu.kanade.presentation.entries.components.DotSeparatorText
import eu.kanade.presentation.entries.components.ItemCover
import eu.kanade.presentation.entries.manga.components.ChapterDownloadAction
Expand Down Expand Up @@ -92,7 +92,7 @@ internal fun LazyListScope.mangaUpdatesUiItems(
is MangaUpdatesUiModel.Header -> {
ListGroupHeader(
modifier = Modifier.animateItem(),
text = relativeDateTimeText(item.date),
text = relativeDateText(item.date),
)
}
is MangaUpdatesUiModel.Item -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadCache
import eu.kanade.tachiyomi.data.download.anime.AnimeDownloadManager
import eu.kanade.tachiyomi.data.download.anime.model.AnimeDownload
import eu.kanade.tachiyomi.data.library.anime.AnimeLibraryUpdateJob
import eu.kanade.tachiyomi.util.lang.toLocalDateTime
import eu.kanade.tachiyomi.util.lang.toLocalDate
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.mutate
import kotlinx.collections.immutable.persistentListOf
Expand Down Expand Up @@ -392,8 +392,8 @@ class AnimeUpdatesScreenModel(
return items
.map { AnimeUpdatesUiModel.Item(it) }
.insertSeparators { before, after ->
val beforeDate = before?.item?.update?.dateFetch?.toLocalDateTime()
val afterDate = after?.item?.update?.dateFetch?.toLocalDateTime()
val beforeDate = before?.item?.update?.dateFetch?.toLocalDate()
val afterDate = after?.item?.update?.dateFetch?.toLocalDate()
when {
beforeDate != afterDate && afterDate != null -> AnimeUpdatesUiModel.Header(afterDate)
// Return null to avoid adding a separator between two items.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import eu.kanade.tachiyomi.data.download.manga.MangaDownloadCache
import eu.kanade.tachiyomi.data.download.manga.MangaDownloadManager
import eu.kanade.tachiyomi.data.download.manga.model.MangaDownload
import eu.kanade.tachiyomi.data.library.manga.MangaLibraryUpdateJob
import eu.kanade.tachiyomi.util.lang.toLocalDateTime
import eu.kanade.tachiyomi.util.lang.toLocalDate
import kotlinx.collections.immutable.PersistentList
import kotlinx.collections.immutable.mutate
import kotlinx.collections.immutable.persistentListOf
Expand Down Expand Up @@ -373,8 +373,8 @@ class MangaUpdatesScreenModel(
return items
.map { MangaUpdatesUiModel.Item(it) }
.insertSeparators { before, after ->
val beforeDate = before?.item?.update?.dateFetch?.toLocalDateTime()
val afterDate = after?.item?.update?.dateFetch?.toLocalDateTime()
val beforeDate = before?.item?.update?.dateFetch?.toLocalDate()
val afterDate = after?.item?.update?.dateFetch?.toLocalDate()
when {
beforeDate != afterDate && afterDate != null -> MangaUpdatesUiModel.Header(afterDate)
// Return null to avoid adding a separator between two items.
Expand Down

0 comments on commit c83ebf3

Please sign in to comment.