Fix "Add manga to library" snackbar not showing with ChapterDownloadAction.START_NOW (#8271)

This commit is contained in:
AntsyLich 2022-10-22 20:12:06 +06:00 committed by GitHub
parent 9c8ccb8e0e
commit b3557e844c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -376,8 +376,7 @@ class MangaController : FullComposeController<MangaPresenter> {
}
}
ChapterDownloadAction.START_NOW -> {
val chapterId = items.singleOrNull()?.chapter?.id ?: return@launch
presenter.startDownloadingNow(chapterId)
downloadChapters(items.map { it.chapter }, startNow = true)
}
ChapterDownloadAction.CANCEL -> {
val chapterId = items.singleOrNull()?.chapter?.id ?: return@launch
@ -390,8 +389,13 @@ class MangaController : FullComposeController<MangaPresenter> {
}
}
private suspend fun downloadChapters(chapters: List<DomainChapter>) {
presenter.downloadChapters(chapters)
private suspend fun downloadChapters(chapters: List<DomainChapter>, startNow: Boolean = false) {
if (startNow) {
val chapterId = chapters.singleOrNull()?.id ?: return
presenter.startDownloadingNow(chapterId)
} else {
presenter.downloadChapters(chapters)
}
if (!presenter.isFavoritedManga) {
val result = snackbarHostState.showSnackbar(