Don't show update progress notifications if job isn't active anymore (closes #5844)
(cherry picked from commit 7083b3d912a93b774f80adf760fdc32540c09b8d) # Conflicts: # app/src/main/java/eu/kanade/tachiyomi/data/library/LibraryUpdateService.kt
This commit is contained in:
parent
74c394193a
commit
c45019e19c
@ -373,13 +373,11 @@ class LibraryUpdateService(
|
|||||||
return@async
|
return@async
|
||||||
}
|
}
|
||||||
|
|
||||||
currentlyUpdatingManga.add(manga)
|
withUpdateNotification(
|
||||||
notifier.showProgressNotification(
|
|
||||||
currentlyUpdatingManga,
|
currentlyUpdatingManga,
|
||||||
progressCount.get(),
|
progressCount,
|
||||||
mangaToUpdate.size
|
manga,
|
||||||
)
|
) { manga ->
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val (newChapters, _) = updateManga(manga, loggedServices)
|
val (newChapters, _) = updateManga(manga, loggedServices)
|
||||||
|
|
||||||
@ -396,32 +394,30 @@ class LibraryUpdateService(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
val errorMessage = if (e is NoChaptersException) {
|
val errorMessage = when (e) {
|
||||||
|
is NoChaptersException -> {
|
||||||
getString(R.string.no_chapters_error)
|
getString(R.string.no_chapters_error)
|
||||||
} else if (e is SourceManager.SourceNotInstalledException) {
|
}
|
||||||
|
is SourceManager.SourceNotInstalledException -> {
|
||||||
// failedUpdates will already have the source, don't need to copy it into the message
|
// failedUpdates will already have the source, don't need to copy it into the message
|
||||||
getString(R.string.loader_not_implemented_error)
|
getString(R.string.loader_not_implemented_error)
|
||||||
} else {
|
}
|
||||||
|
else -> {
|
||||||
e.message
|
e.message
|
||||||
}
|
}
|
||||||
|
}
|
||||||
failedUpdates.add(manga to errorMessage)
|
failedUpdates.add(manga to errorMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferences.autoUpdateTrackers()) {
|
if (preferences.autoUpdateTrackers()) {
|
||||||
updateTrackings(manga, loggedServices)
|
updateTrackings(manga, loggedServices)
|
||||||
}
|
}
|
||||||
|
|
||||||
currentlyUpdatingManga.remove(manga)
|
|
||||||
progressCount.andIncrement
|
|
||||||
notifier.showProgressNotification(
|
|
||||||
currentlyUpdatingManga,
|
|
||||||
progressCount.get(),
|
|
||||||
mangaToUpdate.size
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.awaitAll()
|
}
|
||||||
|
}
|
||||||
|
.awaitAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
notifier.cancelProgressNotification()
|
notifier.cancelProgressNotification()
|
||||||
@ -523,13 +519,11 @@ class LibraryUpdateService(
|
|||||||
return@async
|
return@async
|
||||||
}
|
}
|
||||||
|
|
||||||
currentlyUpdatingManga.add(manga)
|
withUpdateNotification(
|
||||||
notifier.showProgressNotification(
|
|
||||||
currentlyUpdatingManga,
|
currentlyUpdatingManga,
|
||||||
progressCount.get(),
|
progressCount,
|
||||||
mangaToUpdate.size
|
manga,
|
||||||
)
|
) { manga ->
|
||||||
|
|
||||||
sourceManager.get(manga.source)?.let { source ->
|
sourceManager.get(manga.source)?.let { source ->
|
||||||
try {
|
try {
|
||||||
val networkManga =
|
val networkManga =
|
||||||
@ -557,6 +551,7 @@ class LibraryUpdateService(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.awaitAll()
|
.awaitAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,6 +606,38 @@ class LibraryUpdateService(
|
|||||||
.awaitAll()
|
.awaitAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private suspend fun withUpdateNotification(
|
||||||
|
updatingManga: CopyOnWriteArrayList<LibraryManga>,
|
||||||
|
completed: AtomicInteger,
|
||||||
|
manga: LibraryManga,
|
||||||
|
block: suspend (LibraryManga) -> Unit,
|
||||||
|
) {
|
||||||
|
if (updateJob?.isActive != true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
updatingManga.add(manga)
|
||||||
|
notifier.showProgressNotification(
|
||||||
|
updatingManga,
|
||||||
|
completed.get(),
|
||||||
|
mangaToUpdate.size
|
||||||
|
)
|
||||||
|
|
||||||
|
block(manga)
|
||||||
|
|
||||||
|
if (updateJob?.isActive != true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
updatingManga.remove(manga)
|
||||||
|
completed.andIncrement
|
||||||
|
notifier.showProgressNotification(
|
||||||
|
updatingManga,
|
||||||
|
completed.get(),
|
||||||
|
mangaToUpdate.size
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
/**
|
/**
|
||||||
* filter all follows from Mangadex and only add reading or rereading manga to library
|
* filter all follows from Mangadex and only add reading or rereading manga to library
|
||||||
|
Loading…
x
Reference in New Issue
Block a user