fix: wrong initial number of migrating items

This commit is contained in:
Cuong-Tran 2024-08-08 17:58:11 +07:00 committed by Tran M. Cuong
parent 2b3f082690
commit 27ca4af744
3 changed files with 8 additions and 8 deletions

View file

@ -44,7 +44,7 @@ import tachiyomi.presentation.core.util.plus
fun MigrationListScreen(
items: ImmutableList<MigratingManga>,
migrationDone: Boolean,
unfinishedCount: Int,
finishedCount: Int,
getManga: suspend (MigratingManga.SearchResult.Result) -> Manga?,
getChapterInfo: suspend (MigratingManga.SearchResult.Result) -> MigratingManga.ChapterInfo,
getSourceName: (Manga) -> String,
@ -58,9 +58,9 @@ fun MigrationListScreen(
Scaffold(
topBar = { scrollBehavior ->
val titleString = stringResource(SYMR.strings.migration)
val title by produceState(initialValue = titleString, items, unfinishedCount, titleString) {
val title by produceState(initialValue = titleString, items, finishedCount, titleString) {
withIOContext {
value = "$titleString ($unfinishedCount/${items.size})"
value = "$titleString ($finishedCount/${items.size})"
}
}
AppBar(

View file

@ -37,7 +37,7 @@ class MigrationListScreen(private val config: MigrationProcedureConfig) : Screen
val screenModel = rememberScreenModel { MigrationListScreenModel(config) }
val items by screenModel.migratingItems.collectAsState()
val migrationDone by screenModel.migrationDone.collectAsState()
val unfinishedCount by screenModel.unfinishedCount.collectAsState()
val finishedCount by screenModel.finishedCount.collectAsState()
val dialog by screenModel.dialog.collectAsState()
val migrateProgress by screenModel.migratingProgress.collectAsState()
val navigator = LocalNavigator.currentOrThrow
@ -97,7 +97,7 @@ class MigrationListScreen(private val config: MigrationProcedureConfig) : Screen
MigrationListScreen(
items = items ?: persistentListOf(),
migrationDone = migrationDone,
unfinishedCount = unfinishedCount,
finishedCount = finishedCount,
getManga = screenModel::getManga,
getChapterInfo = screenModel::getChapterInfo,
getSourceName = screenModel::getSourceName,

View file

@ -89,7 +89,7 @@ class MigrationListScreenModel(
val migratingItems = MutableStateFlow<ImmutableList<MigratingManga>?>(null)
val migrationDone = MutableStateFlow(false)
val unfinishedCount = MutableStateFlow(0)
val finishedCount = MutableStateFlow(0)
val manualMigrations = MutableStateFlow(0)
@ -158,7 +158,7 @@ class MigrationListScreenModel(
private suspend fun runMigrations(mangas: List<MigratingManga>) {
throttleManager.resetThrottle()
unfinishedCount.value = mangas.size
// KMK: finishedCount.value = mangas.size
val useSourceWithMost = preferences.useSourceWithMost().get()
val useSmartSearch = preferences.smartMigration().get()
@ -319,7 +319,7 @@ class MigrationListScreenModel(
}
private suspend fun sourceFinished() {
unfinishedCount.value = migratingItems.value.orEmpty().count {
finishedCount.value = migratingItems.value.orEmpty().count {
it.searchResult.value != SearchResult.Searching
}
if (allMangasDone()) {