MangaScreenModel: Start downloads in IO dispatcher (#10241)

(cherry picked from commit 09531e7f5a33508afb4a53542ce7b0f601be8826)
This commit is contained in:
Ivan Iskandar 2023-12-17 21:55:54 +07:00 committed by Jobobby04
parent d6b314473d
commit b53cbd7d05

View File

@ -1114,18 +1114,18 @@ class MangaScreenModel(
) {
val successState = successState ?: return
if (startNow) {
val chapterId = chapters.singleOrNull()?.id ?: return
downloadManager.startDownloadNow(chapterId)
} else {
downloadChapters(chapters)
}
if (!isFavorited && !successState.hasPromptedToAddBefore) {
updateSuccessState { state ->
state.copy(hasPromptedToAddBefore = true)
screenModelScope.launchNonCancellable {
if (startNow) {
val chapterId = chapters.singleOrNull()?.id ?: return@launchNonCancellable
downloadManager.startDownloadNow(chapterId)
} else {
downloadChapters(chapters)
}
screenModelScope.launch {
if (!isFavorited && !successState.hasPromptedToAddBefore) {
updateSuccessState { state ->
state.copy(hasPromptedToAddBefore = true)
}
val result = snackbarHostState.showSnackbar(
message = context.stringResource(MR.strings.snack_add_to_library),
actionLabel = context.stringResource(MR.strings.action_add),