Don't update library items on starting service update

This commit is contained in:
Jays2Kings 2022-04-29 19:11:44 -04:00
parent 790ab499f9
commit 203089e1b7
3 changed files with 13 additions and 7 deletions

View file

@ -239,7 +239,7 @@ class LibraryUpdateService(
stopSelf(startId)
}
if (target == Target.CHAPTERS) {
listener?.onUpdateManga()
listener?.onUpdateManga(Manga.create(STARTING_UPDATE_SOURCE))
}
job = GlobalScope.launch(handler) {
when (target) {
@ -592,6 +592,7 @@ class LibraryUpdateService(
* Key for category to update.
*/
const val KEY_CATEGORY = "category"
const val STARTING_UPDATE_SOURCE = -5L
fun categoryInQueue(id: Int?) = instance?.categoryIds?.contains(id) ?: false
private var instance: LibraryUpdateService? = null

View file

@ -1460,6 +1460,7 @@ class LibraryController(
@SuppressLint("NotifyDataSetChanged")
override fun onUpdateManga(manga: Manga?) {
if (manga?.source == LibraryUpdateService.STARTING_UPDATE_SOURCE) return
if (manga == null) adapter.notifyDataSetChanged()
else presenter.updateManga()
}

View file

@ -394,14 +394,18 @@ class RecentsPresenter(
}
override fun onUpdateManga(manga: Manga?) {
if (manga == null && !LibraryUpdateService.isRunning()) {
when {
manga == null -> {
presenterScope.launchUI { controller?.setRefreshing(false) }
} else if (manga == null) {
}
manga.source == LibraryUpdateService.STARTING_UPDATE_SOURCE -> {
presenterScope.launchUI { controller?.setRefreshing(true) }
} else {
}
else -> {
getRecents()
}
}
}
/**
* Deletes the given list of chapter.