Initialize manga on add to library (#1016)

In case a manga gets added to the library which has not been initialized yet, it should be tried to initialize it.
Since it's not an error to have uninitialized manga in the library, this can be done in the background via the updater and the client receives the updated data via the update subscription.
This commit is contained in:
schroda
2024-09-01 00:54:30 +02:00
committed by GitHub
parent 7fac538ba3
commit 5b08b81239
3 changed files with 24 additions and 3 deletions

View File

@@ -3,6 +3,7 @@ package suwayomi.tachidesk.manga.impl.update
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.StateFlow
import suwayomi.tachidesk.manga.model.dataclass.CategoryDataClass
import suwayomi.tachidesk.manga.model.dataclass.MangaDataClass
interface IUpdater {
fun getLastUpdateTimestamp(): Long
@@ -13,6 +14,8 @@ interface IUpdater {
forceAll: Boolean,
)
fun addMangasToQueue(mangas: List<MangaDataClass>)
val status: Flow<UpdateStatus>
val statusDeprecated: StateFlow<UpdateStatus>

View File

@@ -329,11 +329,11 @@ class Updater : IUpdater {
)
}
private fun addMangasToQueue(mangasToUpdate: List<MangaDataClass>) {
override fun addMangasToQueue(mangas: List<MangaDataClass>) {
// create all manga update jobs before adding them to the queue so that the client is able to calculate the
// progress properly right form the start
mangasToUpdate.forEach { tracker[it.id] = UpdateJob(it) }
mangasToUpdate.forEach { addMangaToQueue(it) }
mangas.forEach { tracker[it.id] = UpdateJob(it) }
mangas.forEach { addMangaToQueue(it) }
}
private fun addMangaToQueue(manga: MangaDataClass) {