From 94cf9d77b57b0960b6274e11496d1fe33dc1f349 Mon Sep 17 00:00:00 2001 From: Syer10 Date: Sat, 5 Nov 2022 11:56:58 -0400 Subject: [PATCH] Toast errors where possible --- .../categories/CategoriesScreenViewModel.kt | 14 +++++----- .../ui/downloads/DownloadsScreenViewModel.kt | 12 ++++----- .../extensions/ExtensionsScreenViewModel.kt | 10 +++---- .../jui/ui/library/LibraryScreenViewModel.kt | 6 ++--- .../ca/gosyer/jui/ui/main/MainViewModel.kt | 3 +-- .../jui/ui/main/about/AboutViewModel.kt | 4 +-- .../jui/ui/manga/MangaScreenViewModel.kt | 27 ++++++++++--------- .../jui/ui/reader/ReaderMenuViewModel.kt | 8 +++--- .../jui/ui/settings/SettingsBackupScreen.kt | 3 +++ .../jui/ui/settings/SettingsLibraryScreen.kt | 2 +- .../browse/filter/SourceFiltersViewModel.kt | 17 +++++++----- .../globalsearch/GlobalSearchViewModel.kt | 1 + .../sources/home/SourceHomeScreenViewModel.kt | 1 + .../settings/SourceSettingsScreenViewModel.kt | 7 ++++- .../jui/ui/updates/UpdatesScreenViewModel.kt | 3 ++- 15 files changed, 66 insertions(+), 52 deletions(-) diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/categories/CategoriesScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/categories/CategoriesScreenViewModel.kt index bb484110..334791fc 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/categories/CategoriesScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/categories/CategoriesScreenViewModel.kt @@ -47,7 +47,7 @@ class CategoriesScreenViewModel @Inject constructor( private suspend fun getCategories() { _categories.value = persistentListOf() - val categories = getCategories.await(true) + val categories = getCategories.await(true, onError = { toast(it.message.orEmpty()) }) if (categories != null) { _categories.value = categories .sortedBy { it.order } @@ -61,24 +61,24 @@ class CategoriesScreenViewModel @Inject constructor( val categories = _categories.value val newCategories = categories.filter { it.id == null } newCategories.forEach { - createCategory.await(it.name) + createCategory.await(it.name, onError = { toast(it.message.orEmpty()) }) } originalCategories.forEach { originalCategory -> val category = categories.find { it.id == originalCategory.id } if (category == null) { - deleteCategory.await(originalCategory) + deleteCategory.await(originalCategory, onError = { toast(it.message.orEmpty()) }) } else if (category.name != originalCategory.name) { - modifyCategory.await(originalCategory, category.name) + modifyCategory.await(originalCategory, category.name, onError = { toast(it.message.orEmpty()) }) } } - var updatedCategories = getCategories.await(true) + var updatedCategories = getCategories.await(true, onError = { toast(it.message.orEmpty()) }) categories.forEach { category -> val updatedCategory = updatedCategories?.find { it.id == category.id || it.name == category.name } ?: return@forEach if (category.order != updatedCategory.order) { log.debug { "${category.name}: ${updatedCategory.order} to ${category.order}" } - reorderCategory.await(category.order, updatedCategory.order) + reorderCategory.await(category.order, updatedCategory.order, onError = { toast(it.message.orEmpty()) }) } - updatedCategories = getCategories.await(true) + updatedCategories = getCategories.await(true, onError = { toast(it.message.orEmpty()) }) } if (manualUpdate) { diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt index 33cdc577..ff4495f9 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/downloads/DownloadsScreenViewModel.kt @@ -54,25 +54,25 @@ class DownloadsScreenViewModel @Inject constructor( .stateIn(scope, SharingStarted.Eagerly, persistentListOf()) fun start() { - scope.launch { startDownloading.await() } + scope.launch { startDownloading.await(onError = { toast(it.message.orEmpty()) }) } } fun pause() { - scope.launch { stopDownloading.await() } + scope.launch { stopDownloading.await(onError = { toast(it.message.orEmpty()) }) } } fun clear() { - scope.launch { clearDownloadQueue.await() } + scope.launch { clearDownloadQueue.await(onError = { toast(it.message.orEmpty()) }) } } fun stopDownload(chapter: Chapter) { - scope.launch { stopChapterDownload.await(chapter) } + scope.launch { stopChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) }) } } fun moveToBottom(chapter: Chapter) { scope.launch { - stopChapterDownload.await(chapter) - queueChapterDownload.await(chapter) + stopChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) }) + queueChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) }) } } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/ExtensionsScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/ExtensionsScreenViewModel.kt index 9d64d358..6243e18c 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/ExtensionsScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/extensions/ExtensionsScreenViewModel.kt @@ -80,7 +80,7 @@ class ExtensionsScreenViewModel @Inject constructor( } private suspend fun getExtensions() { - extensionList.value = getExtensionList.await().orEmpty() + extensionList.value = getExtensionList.await(onError = { toast(it.message.orEmpty()) }).orEmpty() _isLoading.value = false } @@ -93,7 +93,7 @@ class ExtensionsScreenViewModel @Inject constructor( .also { file -> source.saveTo(file) } - installExtensionFile.await(file) + installExtensionFile.await(file, onError = { toast(it.message.orEmpty()) }) } catch (e: Exception) { log.warn(e) { "Error creating apk file" } // todo toast if error @@ -107,7 +107,7 @@ class ExtensionsScreenViewModel @Inject constructor( fun install(extension: Extension) { log.info { "Install clicked" } scope.launch { - installExtension.await(extension) + installExtension.await(extension, onError = { toast(it.message.orEmpty()) }) getExtensions() } } @@ -115,7 +115,7 @@ class ExtensionsScreenViewModel @Inject constructor( fun update(extension: Extension) { log.info { "Update clicked" } scope.launch { - updateExtension.await(extension) + updateExtension.await(extension, onError = { toast(it.message.orEmpty()) }) getExtensions() } } @@ -123,7 +123,7 @@ class ExtensionsScreenViewModel @Inject constructor( fun uninstall(extension: Extension) { log.info { "Uninstall clicked" } scope.launch { - uninstallExtension.await(extension) + uninstallExtension.await(extension, onError = { toast(it.message.orEmpty()) }) getExtensions() } } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt index 4f82f526..73bcece3 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/library/LibraryScreenViewModel.kt @@ -288,7 +288,7 @@ class LibraryScreenViewModel @Inject constructor( fun removeManga(mangaId: Long) { scope.launch { - removeMangaFromLibrary.await(mangaId) + removeMangaFromLibrary.await(mangaId, onError = { toast(it.message.orEmpty()) }) } } @@ -297,11 +297,11 @@ class LibraryScreenViewModel @Inject constructor( } fun updateLibrary() { - scope.launch { updateLibrary.await() } + scope.launch { updateLibrary.await(onError = { toast(it.message.orEmpty()) }) } } fun updateCategory(category: Category) { - scope.launch { updateCategory.await(category) } + scope.launch { updateCategory.await(category, onError = { toast(it.message.orEmpty()) }) } } private companion object { diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/MainViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/MainViewModel.kt index 98153628..d5c817d6 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/MainViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/MainViewModel.kt @@ -9,7 +9,6 @@ package ca.gosyer.jui.ui.main import ca.gosyer.jui.domain.ui.service.UiPreferences import ca.gosyer.jui.i18n.MR import ca.gosyer.jui.uicore.vm.ContextWrapper -import ca.gosyer.jui.uicore.vm.Length import ca.gosyer.jui.uicore.vm.ViewModel import kotlinx.coroutines.MainScope import kotlinx.coroutines.cancel @@ -30,6 +29,6 @@ class MainViewModel @Inject constructor( } fun confirmExitToast() { - toast(MR.strings.confirm_exit_toast.toPlatformString(), Length.SHORT) + toast(MR.strings.confirm_exit_toast.toPlatformString()) } } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt index 6af1f311..a564d2b5 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/main/about/AboutViewModel.kt @@ -49,13 +49,13 @@ class AboutViewModel @Inject constructor( private fun getAbout() { scope.launch { - _aboutHolder.value = aboutServer.await() + _aboutHolder.value = aboutServer.await(onError = { toast(it.message.orEmpty()) }) } } fun checkForUpdates() { scope.launch { - when (val update = updateChecker.await(true)) { + when (val update = updateChecker.await(true, onError = { toast(it.message.orEmpty()) })) { is Update.UpdateFound -> _updates.emit(update) else -> Unit } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt index 64b4a608..31a5d89b 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/manga/MangaScreenViewModel.kt @@ -84,7 +84,10 @@ class MangaScreenViewModel @Inject constructor( val categories = getCategories.asFlow(true) .map { it.toImmutableList() } - .catch { log.warn(it) { "Failed to get categories" } } + .catch { + toast(it.message.orEmpty()) + log.warn(it) { "Failed to get categories" } + } .stateIn(scope, SharingStarted.Eagerly, persistentListOf()) private val _mangaCategories = MutableStateFlow>(persistentListOf()) @@ -169,14 +172,12 @@ class MangaScreenViewModel @Inject constructor( private suspend fun refreshChaptersAsync(mangaId: Long, refresh: Boolean = false) = withIOContext { async { val chapters = if (refresh) { - refreshChapters.await(mangaId) + refreshChapters.await(mangaId, onError = { toast(it.message.orEmpty()) }) } else { - getChapters.await(mangaId) + getChapters.await(mangaId, onError = { toast(it.message.orEmpty()) }) } if (chapters != null) { _chapters.value = chapters.toDownloadChapters() - } else { - // TODO: 2022-07-01 Error toast } } } @@ -185,7 +186,7 @@ class MangaScreenViewModel @Inject constructor( scope.launch { manga.value?.let { manga -> if (manga.inLibrary) { - removeMangaFromLibrary.await(manga) + removeMangaFromLibrary.await(manga, onError = { toast(it.message.orEmpty()) }) refreshMangaAsync(manga.id).await() } else { if (categories.value.isEmpty()) { @@ -203,13 +204,13 @@ class MangaScreenViewModel @Inject constructor( manga.value?.let { manga -> if (manga.inLibrary) { oldCategories.filterNot { it in categories }.forEach { - removeMangaFromCategory.await(manga, it) + removeMangaFromCategory.await(manga, it, onError = { toast(it.message.orEmpty()) }) } } else { - addMangaToLibrary.await(manga) + addMangaToLibrary.await(manga, onError = { toast(it.message.orEmpty()) }) } categories.filterNot { it in oldCategories }.forEach { - addMangaToCategory.await(manga, it) + addMangaToCategory.await(manga, it, onError = { toast(it.message.orEmpty()) }) } refreshMangaAsync(manga.id).await() } @@ -222,7 +223,7 @@ class MangaScreenViewModel @Inject constructor( val chapter = findChapter(index) ?: return scope.launch { manga.value?.let { manga -> - updateChapterRead.await(manga, index, read = chapter.read.not()) + updateChapterRead.await(manga, index, read = chapter.read.not(), onError = { toast(it.message.orEmpty()) }) refreshChaptersAsync(manga.id).await() } } @@ -232,7 +233,7 @@ class MangaScreenViewModel @Inject constructor( val chapter = findChapter(index) ?: return scope.launch { manga.value?.let { manga -> - updateChapterBookmarked.await(manga, index, bookmarked = chapter.bookmarked.not()) + updateChapterBookmarked.await(manga, index, bookmarked = chapter.bookmarked.not(), onError = { toast(it.message.orEmpty()) }) refreshChaptersAsync(manga.id).await() } } @@ -241,7 +242,7 @@ class MangaScreenViewModel @Inject constructor( fun markPreviousRead(index: Int) { scope.launch { manga.value?.let { manga -> - updateChapterMarkPreviousRead.await(manga, index) + updateChapterMarkPreviousRead.await(manga, index, onError = { toast(it.message.orEmpty()) }) refreshChaptersAsync(manga.id).await() } } @@ -249,7 +250,7 @@ class MangaScreenViewModel @Inject constructor( fun downloadChapter(index: Int) { manga.value?.let { manga -> - scope.launch { queueChapterDownload.await(manga, index) } + scope.launch { queueChapterDownload.await(manga, index, onError = { toast(it.message.orEmpty()) }) } } } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt index efe66c82..d9ccd67d 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/reader/ReaderMenuViewModel.kt @@ -191,7 +191,7 @@ class ReaderMenuViewModel @Inject constructor( fun setMangaReaderMode(mode: String) { scope.launchDefault { _manga.value?.let { - updateMangaMeta.await(it, mode) + updateMangaMeta.await(it, mode, onError = { toast(it.message.orEmpty()) }) } initManga(params.mangaId) } @@ -307,14 +307,14 @@ class ReaderMenuViewModel @Inject constructor( } private fun markChapterRead(chapter: ReaderChapter) { - scope.launch { updateChapterRead.await(chapter.chapter, read = true) } + scope.launch { updateChapterRead.await(chapter.chapter, read = true, onError = { toast(it.message.orEmpty()) }) } } @OptIn(DelicateCoroutinesApi::class) fun sendProgress(chapter: Chapter? = this.chapter.value?.chapter, lastPageRead: Int = currentPage.value) { chapter ?: return if (chapter.read) return - GlobalScope.launch { updateChapterLastPageRead.await(chapter, lastPageRead = lastPageRead) } + GlobalScope.launch { updateChapterLastPageRead.await(chapter, lastPageRead = lastPageRead, onError = { toast(it.message.orEmpty()) }) } } fun updateLastPageReadOffset(offset: Int) { @@ -323,7 +323,7 @@ class ReaderMenuViewModel @Inject constructor( @OptIn(DelicateCoroutinesApi::class) private fun updateLastPageReadOffset(chapter: Chapter, offset: Int) { - GlobalScope.launch { updateChapterMeta.await(chapter, offset) } + GlobalScope.launch { updateChapterMeta.await(chapter, offset, onError = { toast(it.message.orEmpty()) }) } } override fun onDispose() { diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsBackupScreen.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsBackupScreen.kt index 4b20fc8a..a520171d 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsBackupScreen.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsBackupScreen.kt @@ -157,6 +157,7 @@ class SettingsBackupViewModel @Inject constructor( } } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Error importing backup" } _restoreStatus.value = Status.Error } @@ -181,6 +182,7 @@ class SettingsBackupViewModel @Inject constructor( _restoreStatus.value = Status.Success } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Error importing backup" } _restoreStatus.value = Status.Error } @@ -228,6 +230,7 @@ class SettingsBackupViewModel @Inject constructor( _createFlow.emit(filename) } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Error exporting backup" } _creatingStatus.value = Status.Error } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsLibraryScreen.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsLibraryScreen.kt index bfa118cd..904efef0 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsLibraryScreen.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/settings/SettingsLibraryScreen.kt @@ -114,7 +114,7 @@ class SettingsLibraryViewModel @Inject constructor( fun refreshCategoryCount() { scope.launch { - _categories.value = getCategories.await(true)?.size ?: 0 + _categories.value = getCategories.await(true, onError = { toast(it.message.orEmpty()) })?.size ?: 0 } } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/filter/SourceFiltersViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/filter/SourceFiltersViewModel.kt index 62141506..594dd940 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/filter/SourceFiltersViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/browse/filter/SourceFiltersViewModel.kt @@ -76,10 +76,11 @@ class SourceFiltersViewModel( .filterNotNull() .onEach { setSourceFilter.await( - sourceId, - filter.index, - childFilter.index, - it + sourceId = sourceId, + filterIndex = filter.index, + childFilterIndex = childFilter.index, + filter = it, + onError = { toast(it.message.orEmpty()) } ) getFilters() } @@ -89,9 +90,10 @@ class SourceFiltersViewModel( filter.state.drop(1).filterNotNull() .onEach { setSourceFilter.await( - sourceId, - filter.index, - it + sourceId = sourceId, + filterIndex = filter.index, + filter = it, + onError = { toast(it.message.orEmpty()) } ) getFilters() } @@ -117,6 +119,7 @@ class SourceFiltersViewModel( _loading.value = false } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Error getting filters" } _loading.value = false } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/globalsearch/GlobalSearchViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/globalsearch/GlobalSearchViewModel.kt index 53057035..d7a26c3d 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/globalsearch/GlobalSearchViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/globalsearch/GlobalSearchViewModel.kt @@ -87,6 +87,7 @@ class GlobalSearchViewModel @Inject constructor( _isLoading.value = false } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Error getting sources" } _isLoading.value = false } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/home/SourceHomeScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/home/SourceHomeScreenViewModel.kt index 5033826c..c9870c2f 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/home/SourceHomeScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/home/SourceHomeScreenViewModel.kt @@ -104,6 +104,7 @@ class SourceHomeScreenViewModel @Inject constructor( _isLoading.value = false } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Error getting sources" } _isLoading.value = false } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/settings/SourceSettingsScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/settings/SourceSettingsScreenViewModel.kt index e27a9fc3..31d02f7b 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/settings/SourceSettingsScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/sources/settings/SourceSettingsScreenViewModel.kt @@ -47,7 +47,11 @@ class SourceSettingsScreenViewModel @Inject constructor( setting.state.drop(1) .filterNotNull() .onEach { - setSourceSetting.await(params.sourceId, setting.index, it) + setSourceSetting.await( + sourceId = params.sourceId, + settingIndex = setting.index, + setting = it, + onError = { toast(it.message.orEmpty()) }) getSourceSettings() } .launchIn(this) @@ -63,6 +67,7 @@ class SourceSettingsScreenViewModel @Inject constructor( _loading.value = false } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Error setting source setting" } _loading.value = false } diff --git a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt index 238f2968..3965bb76 100644 --- a/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt +++ b/presentation/src/commonMain/kotlin/ca/gosyer/jui/ui/updates/UpdatesScreenViewModel.kt @@ -121,6 +121,7 @@ class UpdatesScreenViewModel @Inject constructor( _isLoading.value = false } .catch { + toast(it.message.orEmpty()) log.warn(it) { "Failed to get updates for page $page" } if (page > 1) { currentPage.value = page - 1 @@ -131,7 +132,7 @@ class UpdatesScreenViewModel @Inject constructor( } fun downloadChapter(chapter: Chapter) { - scope.launch { queueChapterDownload.await(chapter) } + scope.launch { queueChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) }) } } fun deleteDownloadedChapter(chapter: Chapter) {