mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 00:01:54 +01:00
Don't show update progress notifications if job isn't active anymore (closes #5844)
This commit is contained in:
parent
2d3a1b6a9e
commit
7083b3d912
@ -294,13 +294,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)
|
val (newChapters, _) = updateManga(manga)
|
||||||
|
|
||||||
@ -311,31 +309,31 @@ class LibraryUpdateService(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert to the manga that contains new chapters
|
// Convert to the manga that contains new chapters
|
||||||
newUpdates.add(manga to newChapters.sortedByDescending { ch -> ch.source_order }.toTypedArray())
|
newUpdates.add(
|
||||||
|
manga to newChapters.sortedByDescending { ch -> ch.source_order }
|
||||||
|
.toTypedArray()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
} 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
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,13 +416,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 =
|
||||||
@ -452,6 +448,7 @@ class LibraryUpdateService(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
.awaitAll()
|
.awaitAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,6 +503,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
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes basic file of update errors to cache dir.
|
* Writes basic file of update errors to cache dir.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user