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

View file

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

View file

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