Drop kotlinx-collections-immutable usage (#3380)

This commit is contained in:
AntsyLich
2026-06-04 02:45:24 +06:00
committed by GitHub
parent 7f8851de6a
commit cd27b10750
91 changed files with 317 additions and 523 deletions
@@ -25,8 +25,6 @@ import cafe.adriel.voyager.navigator.currentOrThrow
import eu.kanade.presentation.components.AppBar
import eu.kanade.presentation.components.relativeDateText
import eu.kanade.presentation.util.isTabletUi
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.coroutines.launch
import mihon.feature.upcoming.components.UpcomingItem
import mihon.feature.upcoming.components.calendar.Calendar
@@ -136,8 +134,8 @@ private fun DateHeading(
@Composable
private fun UpcomingScreenSmallImpl(
listState: LazyListState,
items: ImmutableList<UpcomingUIModel>,
events: ImmutableMap<LocalDate, Int>,
items: List<UpcomingUIModel>,
events: Map<LocalDate, Int>,
paddingValues: PaddingValues,
selectedYearMonth: YearMonth,
setSelectedYearMonth: (YearMonth) -> Unit,
@@ -187,8 +185,8 @@ private fun UpcomingScreenSmallImpl(
@Composable
private fun UpcomingScreenLargeImpl(
listState: LazyListState,
items: ImmutableList<UpcomingUIModel>,
events: ImmutableMap<LocalDate, Int>,
items: List<UpcomingUIModel>,
events: Map<LocalDate, Int>,
paddingValues: PaddingValues,
selectedYearMonth: YearMonth,
setSelectedYearMonth: (YearMonth) -> Unit,
@@ -6,12 +6,6 @@ import cafe.adriel.voyager.core.model.StateScreenModel
import cafe.adriel.voyager.core.model.screenModelScope
import eu.kanade.core.util.insertSeparatorsReversed
import eu.kanade.tachiyomi.util.lang.toLocalDate
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.persistentMapOf
import kotlinx.collections.immutable.toImmutableList
import kotlinx.collections.immutable.toImmutableMap
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.launch
@@ -41,7 +35,7 @@ class UpcomingScreenModel(
}
}
private fun List<Manga>.toUpcomingUIModels(): ImmutableList<UpcomingUIModel> {
private fun List<Manga>.toUpcomingUIModels(): List<UpcomingUIModel> {
var mangaCount = 0
return fastMap { UpcomingUIModel.Item(it) }
.insertSeparatorsReversed { before, after ->
@@ -56,16 +50,14 @@ class UpcomingScreenModel(
null
}
}
.toImmutableList()
}
private fun List<UpcomingUIModel>.toEvents(): ImmutableMap<LocalDate, Int> {
private fun List<UpcomingUIModel>.toEvents(): Map<LocalDate, Int> {
return filterIsInstance<UpcomingUIModel.Header>()
.associate { it.date to it.mangaCount }
.toImmutableMap()
}
private fun List<UpcomingUIModel>.getHeaderIndexes(): ImmutableMap<LocalDate, Int> {
private fun List<UpcomingUIModel>.getHeaderIndexes(): Map<LocalDate, Int> {
return fastMapIndexedNotNull { index, upcomingUIModel ->
if (upcomingUIModel is UpcomingUIModel.Header) {
upcomingUIModel.date to index
@@ -74,7 +66,6 @@ class UpcomingScreenModel(
}
}
.toMap()
.toImmutableMap()
}
fun setSelectedYearMonth(yearMonth: YearMonth) {
@@ -83,8 +74,8 @@ class UpcomingScreenModel(
data class State(
val selectedYearMonth: YearMonth = YearMonth.now(),
val items: ImmutableList<UpcomingUIModel> = persistentListOf(),
val events: ImmutableMap<LocalDate, Int> = persistentMapOf(),
val headerIndexes: ImmutableMap<LocalDate, Int> = persistentMapOf(),
val items: List<UpcomingUIModel> = listOf(),
val events: Map<LocalDate, Int> = mapOf(),
val headerIndexes: Map<LocalDate, Int> = mapOf(),
)
}
@@ -19,8 +19,6 @@ import androidx.compose.ui.unit.sp
import androidx.compose.ui.util.fastForEach
import io.woong.compose.grid.SimpleGridCells
import io.woong.compose.grid.VerticalGrid
import kotlinx.collections.immutable.ImmutableMap
import kotlinx.collections.immutable.toImmutableList
import mihon.core.designsystem.utils.isExpandedWidthWindow
import mihon.core.designsystem.utils.isMediumWidthWindow
import tachiyomi.presentation.core.components.material.padding
@@ -37,7 +35,7 @@ private const val DAYS_OF_WEEK = 7
@Composable
fun Calendar(
selectedYearMonth: YearMonth,
events: ImmutableMap<LocalDate, Int>,
events: Map<LocalDate, Int>,
setSelectedYearMonth: (YearMonth) -> Unit,
onClickDay: (day: LocalDate) -> Unit,
modifier: Modifier = Modifier,
@@ -67,14 +65,13 @@ fun Calendar(
@Composable
private fun CalendarGrid(
selectedYearMonth: YearMonth,
events: ImmutableMap<LocalDate, Int>,
events: Map<LocalDate, Int>,
onClickDay: (day: LocalDate) -> Unit,
) {
val localeFirstDayOfWeek = WeekFields.of(Locale.getDefault()).firstDayOfWeek.value
val weekDays = remember {
(0 until DAYS_OF_WEEK)
.map { DayOfWeek.of((localeFirstDayOfWeek - 1 + it) % DAYS_OF_WEEK + 1) }
.toImmutableList()
}
val emptyFieldCount = weekDays.indexOf(selectedYearMonth.atDay(1).dayOfWeek)