Drop kotlinx-collections-immutable usage (#3380)
This commit is contained in:
@@ -22,7 +22,6 @@ import eu.kanade.tachiyomi.ui.browse.migration.sources.migrateSourceTab
|
||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchScreen
|
||||
import eu.kanade.tachiyomi.ui.browse.source.sourcesTab
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.channels.BufferOverflow
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
@@ -62,7 +61,7 @@ data object BrowseTab : Tab {
|
||||
val extensionsScreenModel = rememberScreenModel { ExtensionsScreenModel() }
|
||||
val extensionsState by extensionsScreenModel.state.collectAsState()
|
||||
|
||||
val tabs = persistentListOf(
|
||||
val tabs = listOf(
|
||||
sourcesTab(),
|
||||
extensionsTab(extensionsScreenModel),
|
||||
migrateSourceTab(),
|
||||
|
||||
+4
-9
@@ -6,11 +6,6 @@ import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import eu.kanade.domain.extension.interactor.GetExtensionLanguages
|
||||
import eu.kanade.domain.source.interactor.ToggleLanguage
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.ImmutableSet
|
||||
import kotlinx.collections.immutable.persistentSetOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableSet
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -46,8 +41,8 @@ class ExtensionFilterScreenModel(
|
||||
.collectLatest { (extensionLanguages, enabledLanguages) ->
|
||||
mutableState.update {
|
||||
ExtensionFilterState.Success(
|
||||
languages = extensionLanguages.toImmutableList(),
|
||||
enabledLanguages = enabledLanguages.toImmutableSet(),
|
||||
languages = extensionLanguages,
|
||||
enabledLanguages = enabledLanguages,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -70,8 +65,8 @@ sealed interface ExtensionFilterState {
|
||||
|
||||
@Immutable
|
||||
data class Success(
|
||||
val languages: ImmutableList<String>,
|
||||
val enabledLanguages: ImmutableSet<String> = persistentSetOf(),
|
||||
val languages: List<String>,
|
||||
val enabledLanguages: Set<String> = setOf(),
|
||||
) : ExtensionFilterState {
|
||||
|
||||
val isEmpty: Boolean
|
||||
|
||||
@@ -21,7 +21,6 @@ import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.ui.browse.extension.details.ExtensionDetailsScreen
|
||||
import eu.kanade.tachiyomi.ui.webview.WebViewScreen
|
||||
import eu.kanade.tachiyomi.util.system.isPackageInstalled
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
||||
@@ -39,7 +38,7 @@ fun extensionsTab(
|
||||
titleRes = MR.strings.label_extensions,
|
||||
badgeNumber = state.updates.takeIf { it > 0 },
|
||||
searchEnabled = true,
|
||||
actions = persistentListOf(
|
||||
actions = listOf(
|
||||
AppBar.OverflowAction(
|
||||
title = stringResource(MR.strings.action_filter),
|
||||
onClick = { navigator.push(ExtensionFilterScreen()) },
|
||||
|
||||
+5
-8
@@ -14,9 +14,6 @@ import eu.kanade.tachiyomi.extension.model.Extension
|
||||
import eu.kanade.tachiyomi.network.NetworkHelper
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.system.LocaleHelper
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -78,10 +75,10 @@ class ExtensionDetailsScreenModel(
|
||||
}
|
||||
.catch { throwable ->
|
||||
logcat(LogPriority.ERROR, throwable)
|
||||
mutableState.update { it.copy(_sources = persistentListOf()) }
|
||||
mutableState.update { it.copy(_sources = listOf()) }
|
||||
}
|
||||
.collectLatest { sources ->
|
||||
mutableState.update { it.copy(_sources = sources.toImmutableList()) }
|
||||
mutableState.update { it.copy(_sources = sources) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -142,11 +139,11 @@ class ExtensionDetailsScreenModel(
|
||||
data class State(
|
||||
val extension: Extension.Installed? = null,
|
||||
val isIncognito: Boolean = false,
|
||||
private val _sources: ImmutableList<ExtensionSourceItem>? = null,
|
||||
private val _sources: List<ExtensionSourceItem>? = null,
|
||||
) {
|
||||
|
||||
val sources: ImmutableList<ExtensionSourceItem>
|
||||
get() = _sources ?: persistentListOf()
|
||||
val sources: List<ExtensionSourceItem>
|
||||
get() = _sources ?: listOf()
|
||||
|
||||
val isLoading: Boolean
|
||||
get() = extension == null || _sources == null
|
||||
|
||||
+4
-8
@@ -4,9 +4,6 @@ import androidx.compose.runtime.Immutable
|
||||
import cafe.adriel.voyager.core.model.StateScreenModel
|
||||
import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -44,13 +41,12 @@ class MigrateMangaScreenModel(
|
||||
logcat(LogPriority.ERROR, it)
|
||||
_events.send(MigrationMangaEvent.FailedFetchingFavorites)
|
||||
mutableState.update { state ->
|
||||
state.copy(titleList = persistentListOf())
|
||||
state.copy(titleList = listOf())
|
||||
}
|
||||
}
|
||||
.map { manga ->
|
||||
manga
|
||||
.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.title })
|
||||
.toImmutableList()
|
||||
}
|
||||
.collectLatest { list ->
|
||||
mutableState.update { it.copy(titleList = list) }
|
||||
@@ -75,11 +71,11 @@ class MigrateMangaScreenModel(
|
||||
data class State(
|
||||
val source: Source? = null,
|
||||
val selection: Set<Long> = emptySet(),
|
||||
private val titleList: ImmutableList<Manga>? = null,
|
||||
private val titleList: List<Manga>? = null,
|
||||
) {
|
||||
|
||||
val titles: ImmutableList<Manga>
|
||||
get() = titleList ?: persistentListOf()
|
||||
val titles: List<Manga>
|
||||
get() = titleList ?: listOf()
|
||||
|
||||
val isLoading: Boolean
|
||||
get() = source == null || titleList == null
|
||||
|
||||
+2
-5
@@ -6,9 +6,6 @@ import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import eu.kanade.domain.source.interactor.GetSourcesWithFavoriteCount
|
||||
import eu.kanade.domain.source.interactor.SetMigrateSorting
|
||||
import eu.kanade.domain.source.service.SourcePreferences
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
@@ -43,7 +40,7 @@ class MigrateSourceScreenModel(
|
||||
mutableState.update {
|
||||
it.copy(
|
||||
isLoading = false,
|
||||
items = sources.toImmutableList(),
|
||||
items = sources,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -83,7 +80,7 @@ class MigrateSourceScreenModel(
|
||||
@Immutable
|
||||
data class State(
|
||||
val isLoading: Boolean = true,
|
||||
val items: ImmutableList<Pair<Source, Long>> = persistentListOf(),
|
||||
val items: List<Pair<Source, Long>> = listOf(),
|
||||
val sortingMode: SetMigrateSorting.Mode = SetMigrateSorting.Mode.ALPHABETICAL,
|
||||
val sortingDirection: SetMigrateSorting.Direction = SetMigrateSorting.Direction.ASCENDING,
|
||||
) {
|
||||
|
||||
+1
-2
@@ -14,7 +14,6 @@ import eu.kanade.presentation.browse.MigrateSourceScreen
|
||||
import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.TabContent
|
||||
import eu.kanade.tachiyomi.ui.browse.migration.manga.MigrateMangaScreen
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.i18n.stringResource
|
||||
|
||||
@@ -27,7 +26,7 @@ fun Screen.migrateSourceTab(): TabContent {
|
||||
|
||||
return TabContent(
|
||||
titleRes = MR.strings.label_migration,
|
||||
actions = persistentListOf(
|
||||
actions = listOf(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.migration_help_guide),
|
||||
icon = Icons.AutoMirrored.Outlined.HelpOutline,
|
||||
|
||||
@@ -7,9 +7,6 @@ import eu.kanade.domain.source.interactor.GetEnabledSources
|
||||
import eu.kanade.domain.source.interactor.ToggleSource
|
||||
import eu.kanade.domain.source.interactor.ToggleSourcePin
|
||||
import eu.kanade.presentation.browse.SourceUiModel
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
@@ -76,8 +73,7 @@ class SourcesScreenModel(
|
||||
SourceUiModel.Item(source)
|
||||
}.toTypedArray(),
|
||||
)
|
||||
}
|
||||
.toImmutableList(),
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -108,7 +104,7 @@ class SourcesScreenModel(
|
||||
data class State(
|
||||
val dialog: Dialog? = null,
|
||||
val isLoading: Boolean = true,
|
||||
val items: ImmutableList<SourceUiModel> = persistentListOf(),
|
||||
val items: List<SourceUiModel> = listOf(),
|
||||
) {
|
||||
val isEmpty = items.isEmpty()
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import eu.kanade.presentation.components.AppBar
|
||||
import eu.kanade.presentation.components.TabContent
|
||||
import eu.kanade.tachiyomi.ui.browse.source.browse.BrowseSourceScreen
|
||||
import eu.kanade.tachiyomi.ui.browse.source.globalsearch.GlobalSearchScreen
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.launch
|
||||
import tachiyomi.i18n.MR
|
||||
@@ -31,7 +30,7 @@ fun Screen.sourcesTab(): TabContent {
|
||||
|
||||
return TabContent(
|
||||
titleRes = MR.strings.label_sources,
|
||||
actions = persistentListOf(
|
||||
actions = listOf(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_global_search),
|
||||
icon = Icons.Outlined.TravelExplore,
|
||||
|
||||
+2
-4
@@ -23,8 +23,6 @@ import eu.kanade.tachiyomi.data.cache.CoverCache
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import eu.kanade.tachiyomi.source.model.FilterList
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.SharingStarted
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.emptyFlow
|
||||
@@ -265,7 +263,7 @@ class BrowseSourceScreenModel(
|
||||
setDialog(
|
||||
Dialog.ChangeMangaCategory(
|
||||
manga,
|
||||
categories.mapAsCheckboxState { it.id in preselectedIds }.toImmutableList(),
|
||||
categories.mapAsCheckboxState { it.id in preselectedIds },
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -339,7 +337,7 @@ class BrowseSourceScreenModel(
|
||||
data class AddDuplicateManga(val manga: Manga, val duplicates: List<MangaWithChapterCount>) : Dialog
|
||||
data class ChangeMangaCategory(
|
||||
val manga: Manga,
|
||||
val initialSelection: ImmutableList<CheckboxState.State<Category>>,
|
||||
val initialSelection: List<CheckboxState.State<Category>>,
|
||||
) : Dialog
|
||||
data class Migrate(val target: Manga, val current: Manga) : Dialog
|
||||
}
|
||||
|
||||
+6
-16
@@ -9,10 +9,6 @@ import eu.kanade.domain.source.service.SourcePreferences
|
||||
import eu.kanade.presentation.util.ioCoroutineScope
|
||||
import eu.kanade.tachiyomi.extension.ExtensionManager
|
||||
import eu.kanade.tachiyomi.source.CatalogueSource
|
||||
import kotlinx.collections.immutable.PersistentMap
|
||||
import kotlinx.collections.immutable.mutate
|
||||
import kotlinx.collections.immutable.persistentMapOf
|
||||
import kotlinx.collections.immutable.toPersistentMap
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.async
|
||||
@@ -143,14 +139,12 @@ abstract class SearchScreenModel(
|
||||
val existingResults = state.value.items
|
||||
updateItems(
|
||||
sources
|
||||
.associateWith { existingResults[it] ?: SearchItemResult.Loading }
|
||||
.toPersistentMap(),
|
||||
.associateWith { existingResults[it] ?: SearchItemResult.Loading },
|
||||
)
|
||||
} else {
|
||||
updateItems(
|
||||
sources
|
||||
.associateWith { SearchItemResult.Loading }
|
||||
.toPersistentMap(),
|
||||
.associateWith { SearchItemResult.Loading },
|
||||
)
|
||||
}
|
||||
|
||||
@@ -185,21 +179,17 @@ abstract class SearchScreenModel(
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateItems(items: PersistentMap<CatalogueSource, SearchItemResult>) {
|
||||
private fun updateItems(items: Map<CatalogueSource, SearchItemResult>) {
|
||||
mutableState.update {
|
||||
it.copy(
|
||||
items = items
|
||||
.toSortedMap(sortComparator(items))
|
||||
.toPersistentMap(),
|
||||
.toSortedMap(sortComparator(items)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateItem(source: CatalogueSource, result: SearchItemResult) {
|
||||
val newItems = state.value.items.mutate {
|
||||
it[source] = result
|
||||
}
|
||||
updateItems(newItems)
|
||||
updateItems(state.value.items + (source to result))
|
||||
}
|
||||
|
||||
fun setMigrateDialog(currentId: Long, target: Manga) {
|
||||
@@ -219,7 +209,7 @@ abstract class SearchScreenModel(
|
||||
val searchQuery: String? = null,
|
||||
val sourceFilter: SourceFilter = SourceFilter.PinnedOnly,
|
||||
val onlyShowHasResults: Boolean = false,
|
||||
val items: PersistentMap<CatalogueSource, SearchItemResult> = persistentMapOf(),
|
||||
val items: Map<CatalogueSource, SearchItemResult> = mapOf(),
|
||||
val dialog: Dialog? = null,
|
||||
) {
|
||||
val progress: Int = items.count { it.value !is SearchItemResult.Loading }
|
||||
|
||||
@@ -15,7 +15,6 @@ import eu.kanade.presentation.category.components.CategoryDeleteDialog
|
||||
import eu.kanade.presentation.category.components.CategoryRenameDialog
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import tachiyomi.presentation.core.screens.LoadingScreen
|
||||
|
||||
@@ -51,14 +50,14 @@ class CategoryScreen : Screen() {
|
||||
CategoryCreateDialog(
|
||||
onDismissRequest = screenModel::dismissDialog,
|
||||
onCreate = screenModel::createCategory,
|
||||
categories = successState.categories.fastMap { it.name }.toImmutableList(),
|
||||
categories = successState.categories.fastMap { it.name },
|
||||
)
|
||||
}
|
||||
is CategoryDialog.Rename -> {
|
||||
CategoryRenameDialog(
|
||||
onDismissRequest = screenModel::dismissDialog,
|
||||
onRename = { screenModel.renameCategory(dialog.category, it) },
|
||||
categories = successState.categories.fastMap { it.name }.toImmutableList(),
|
||||
categories = successState.categories.fastMap { it.name },
|
||||
category = dialog.category.name,
|
||||
)
|
||||
}
|
||||
|
||||
@@ -4,8 +4,6 @@ import androidx.compose.runtime.Immutable
|
||||
import cafe.adriel.voyager.core.model.StateScreenModel
|
||||
import cafe.adriel.voyager.core.model.screenModelScope
|
||||
import dev.icerock.moko.resources.StringResource
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
@@ -39,8 +37,7 @@ class CategoryScreenModel(
|
||||
mutableState.update {
|
||||
CategoryScreenState.Success(
|
||||
categories = categories
|
||||
.filterNot(Category::isSystemCategory)
|
||||
.toImmutableList(),
|
||||
.filterNot(Category::isSystemCategory),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -120,7 +117,7 @@ sealed interface CategoryScreenState {
|
||||
|
||||
@Immutable
|
||||
data class Success(
|
||||
val categories: ImmutableList<Category>,
|
||||
val categories: List<Category>,
|
||||
val dialog: CategoryDialog? = null,
|
||||
) : CategoryScreenState {
|
||||
|
||||
|
||||
@@ -51,7 +51,6 @@ import eu.kanade.presentation.components.DropdownMenu
|
||||
import eu.kanade.presentation.components.NestedMenuItem
|
||||
import eu.kanade.presentation.util.Screen
|
||||
import eu.kanade.tachiyomi.databinding.DownloadListBinding
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import tachiyomi.core.common.util.lang.launchUI
|
||||
import tachiyomi.i18n.MR
|
||||
import tachiyomi.presentation.core.components.Pill
|
||||
@@ -181,7 +180,7 @@ object DownloadQueueScreen : Screen() {
|
||||
}
|
||||
|
||||
AppBarActions(
|
||||
persistentListOf(
|
||||
listOf(
|
||||
AppBar.Action(
|
||||
title = stringResource(MR.strings.action_sort),
|
||||
icon = Icons.AutoMirrored.Outlined.Sort,
|
||||
|
||||
@@ -9,8 +9,6 @@ import eu.kanade.domain.manga.interactor.UpdateManga
|
||||
import eu.kanade.domain.track.interactor.AddTracks
|
||||
import eu.kanade.presentation.history.HistoryUiModel
|
||||
import eu.kanade.tachiyomi.util.lang.toLocalDate
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
@@ -230,7 +228,7 @@ class HistoryScreenModel(
|
||||
currentState.copy(
|
||||
dialog = Dialog.ChangeCategory(
|
||||
manga = manga,
|
||||
initialSelection = categories.mapAsCheckboxState { it.id in selection }.toImmutableList(),
|
||||
initialSelection = categories.mapAsCheckboxState { it.id in selection },
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -250,7 +248,7 @@ class HistoryScreenModel(
|
||||
data class DuplicateManga(val manga: Manga, val duplicates: List<MangaWithChapterCount>) : Dialog
|
||||
data class ChangeCategory(
|
||||
val manga: Manga,
|
||||
val initialSelection: ImmutableList<CheckboxState<Category>>,
|
||||
val initialSelection: List<CheckboxState<Category>>,
|
||||
) : Dialog
|
||||
data class Migrate(val target: Manga, val current: Manga) : Dialog
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@ import eu.kanade.tachiyomi.source.model.SManga
|
||||
import eu.kanade.tachiyomi.source.online.HttpSource
|
||||
import eu.kanade.tachiyomi.util.chapter.getNextUnread
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.combine
|
||||
@@ -709,7 +707,7 @@ class LibraryScreenModel(
|
||||
else -> CheckboxState.State.None(it)
|
||||
}
|
||||
}
|
||||
.toImmutableList()
|
||||
|
||||
mutableState.update { it.copy(dialog = Dialog.ChangeCategory(mangaList, preselected)) }
|
||||
}
|
||||
}
|
||||
@@ -726,7 +724,7 @@ class LibraryScreenModel(
|
||||
data object SettingsSheet : Dialog
|
||||
data class ChangeCategory(
|
||||
val manga: List<Manga>,
|
||||
val initialSelection: ImmutableList<CheckboxState<Category>>,
|
||||
val initialSelection: List<CheckboxState<Category>>,
|
||||
) : Dialog
|
||||
data class DeleteManga(val manga: List<Manga>) : Dialog
|
||||
}
|
||||
|
||||
@@ -43,7 +43,6 @@ import eu.kanade.tachiyomi.ui.home.HomeScreen
|
||||
import eu.kanade.tachiyomi.ui.main.MainActivity
|
||||
import eu.kanade.tachiyomi.ui.manga.MangaScreen
|
||||
import eu.kanade.tachiyomi.ui.reader.ReaderActivity
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
@@ -168,7 +167,7 @@ data object LibraryTab : Tab {
|
||||
EmptyScreen(
|
||||
stringRes = MR.strings.information_empty_library,
|
||||
modifier = Modifier.padding(contentPadding),
|
||||
actions = persistentListOf(
|
||||
actions = listOf(
|
||||
EmptyScreenAction(
|
||||
stringRes = MR.strings.getting_started_guide,
|
||||
icon = Icons.AutoMirrored.Outlined.HelpOutline,
|
||||
|
||||
@@ -42,8 +42,6 @@ import eu.kanade.tachiyomi.ui.reader.setting.ReaderPreferences
|
||||
import eu.kanade.tachiyomi.util.chapter.getNextUnread
|
||||
import eu.kanade.tachiyomi.util.removeCovers
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.collections.immutable.toImmutableList
|
||||
import kotlinx.coroutines.async
|
||||
import kotlinx.coroutines.awaitAll
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -374,7 +372,7 @@ class MangaScreenModel(
|
||||
successState.copy(
|
||||
dialog = Dialog.ChangeCategory(
|
||||
manga = manga,
|
||||
initialSelection = categories.mapAsCheckboxState { it.id in selection }.toImmutableList(),
|
||||
initialSelection = categories.mapAsCheckboxState { it.id in selection },
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -1081,7 +1079,7 @@ class MangaScreenModel(
|
||||
sealed interface Dialog {
|
||||
data class ChangeCategory(
|
||||
val manga: Manga,
|
||||
val initialSelection: ImmutableList<CheckboxState<Category>>,
|
||||
val initialSelection: List<CheckboxState<Category>>,
|
||||
) : Dialog
|
||||
data class DeleteChapters(val chapters: List<Chapter>) : Dialog
|
||||
data class DuplicateManga(val manga: Manga, val duplicates: List<MangaWithChapterCount>) : Dialog
|
||||
|
||||
@@ -58,7 +58,6 @@ import eu.kanade.tachiyomi.util.lang.toLocalDate
|
||||
import eu.kanade.tachiyomi.util.system.copyToClipboard
|
||||
import eu.kanade.tachiyomi.util.system.openInBrowser
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.collections.immutable.ImmutableList
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.collectLatest
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
@@ -416,7 +415,7 @@ private data class TrackScoreSelectorScreen(
|
||||
private val tracker: Tracker,
|
||||
) : StateScreenModel<Model.State>(State(tracker.displayScore(track))) {
|
||||
|
||||
fun getSelections(): ImmutableList<String> {
|
||||
fun getSelections(): List<String> {
|
||||
return tracker.getScoreList()
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,6 @@ import eu.kanade.tachiyomi.data.download.DownloadManager
|
||||
import eu.kanade.tachiyomi.data.download.model.Download
|
||||
import eu.kanade.tachiyomi.data.library.LibraryUpdateJob
|
||||
import eu.kanade.tachiyomi.util.lang.toLocalDate
|
||||
import kotlinx.collections.immutable.PersistentList
|
||||
import kotlinx.collections.immutable.mutate
|
||||
import kotlinx.collections.immutable.persistentListOf
|
||||
import kotlinx.collections.immutable.toPersistentList
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.catch
|
||||
@@ -106,7 +102,6 @@ class UpdatesScreenModel(
|
||||
updates
|
||||
.toUpdateItems()
|
||||
.applyFilters(itemPreferences)
|
||||
.toPersistentList()
|
||||
}
|
||||
.collectLatest { updateItems ->
|
||||
mutableState.update {
|
||||
@@ -199,9 +194,9 @@ class UpdatesScreenModel(
|
||||
*/
|
||||
private fun updateDownloadState(download: Download) {
|
||||
mutableState.update { state ->
|
||||
val newItems = state.items.mutate { list ->
|
||||
val newItems = state.items.toMutableList().also { list ->
|
||||
val modifiedIndex = list.indexOfFirst { it.update.chapterId == download.chapter.id }
|
||||
if (modifiedIndex < 0) return@mutate
|
||||
if (modifiedIndex < 0) return@also
|
||||
|
||||
val item = list[modifiedIndex]
|
||||
list[modifiedIndex] = item.copy(
|
||||
@@ -381,7 +376,7 @@ class UpdatesScreenModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
state.copy(items = newItems.toPersistentList())
|
||||
state.copy(items = newItems)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,7 +386,7 @@ class UpdatesScreenModel(
|
||||
selectedChapterIds.addOrRemove(it.update.chapterId, selected)
|
||||
it.copy(selected = selected)
|
||||
}
|
||||
state.copy(items = newItems.toPersistentList())
|
||||
state.copy(items = newItems)
|
||||
}
|
||||
|
||||
selectedPositions[0] = -1
|
||||
@@ -404,7 +399,7 @@ class UpdatesScreenModel(
|
||||
selectedChapterIds.addOrRemove(it.update.chapterId, !it.selected)
|
||||
it.copy(selected = !it.selected)
|
||||
}
|
||||
state.copy(items = newItems.toPersistentList())
|
||||
state.copy(items = newItems)
|
||||
}
|
||||
selectedPositions[0] = -1
|
||||
selectedPositions[1] = -1
|
||||
@@ -453,7 +448,7 @@ class UpdatesScreenModel(
|
||||
data class State(
|
||||
val isLoading: Boolean = true,
|
||||
val hasActiveFilters: Boolean = false,
|
||||
val items: PersistentList<UpdatesItem> = persistentListOf(),
|
||||
val items: List<UpdatesItem> = listOf(),
|
||||
val dialog: Dialog? = null,
|
||||
) {
|
||||
val selected = items.filter { it.selected }
|
||||
|
||||
Reference in New Issue
Block a user