mirror of
https://github.com/Suwayomi/TachideskJUI.git
synced 2025-12-12 07:42:03 +01:00
Toast errors where possible
This commit is contained in:
@@ -47,7 +47,7 @@ class CategoriesScreenViewModel @Inject constructor(
|
|||||||
|
|
||||||
private suspend fun getCategories() {
|
private suspend fun getCategories() {
|
||||||
_categories.value = persistentListOf()
|
_categories.value = persistentListOf()
|
||||||
val categories = getCategories.await(true)
|
val categories = getCategories.await(true, onError = { toast(it.message.orEmpty()) })
|
||||||
if (categories != null) {
|
if (categories != null) {
|
||||||
_categories.value = categories
|
_categories.value = categories
|
||||||
.sortedBy { it.order }
|
.sortedBy { it.order }
|
||||||
@@ -61,24 +61,24 @@ class CategoriesScreenViewModel @Inject constructor(
|
|||||||
val categories = _categories.value
|
val categories = _categories.value
|
||||||
val newCategories = categories.filter { it.id == null }
|
val newCategories = categories.filter { it.id == null }
|
||||||
newCategories.forEach {
|
newCategories.forEach {
|
||||||
createCategory.await(it.name)
|
createCategory.await(it.name, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
originalCategories.forEach { originalCategory ->
|
originalCategories.forEach { originalCategory ->
|
||||||
val category = categories.find { it.id == originalCategory.id }
|
val category = categories.find { it.id == originalCategory.id }
|
||||||
if (category == null) {
|
if (category == null) {
|
||||||
deleteCategory.await(originalCategory)
|
deleteCategory.await(originalCategory, onError = { toast(it.message.orEmpty()) })
|
||||||
} else if (category.name != originalCategory.name) {
|
} 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 ->
|
categories.forEach { category ->
|
||||||
val updatedCategory = updatedCategories?.find { it.id == category.id || it.name == category.name } ?: return@forEach
|
val updatedCategory = updatedCategories?.find { it.id == category.id || it.name == category.name } ?: return@forEach
|
||||||
if (category.order != updatedCategory.order) {
|
if (category.order != updatedCategory.order) {
|
||||||
log.debug { "${category.name}: ${updatedCategory.order} to ${category.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) {
|
if (manualUpdate) {
|
||||||
|
|||||||
@@ -54,25 +54,25 @@ class DownloadsScreenViewModel @Inject constructor(
|
|||||||
.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
||||||
|
|
||||||
fun start() {
|
fun start() {
|
||||||
scope.launch { startDownloading.await() }
|
scope.launch { startDownloading.await(onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun pause() {
|
fun pause() {
|
||||||
scope.launch { stopDownloading.await() }
|
scope.launch { stopDownloading.await(onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clear() {
|
fun clear() {
|
||||||
scope.launch { clearDownloadQueue.await() }
|
scope.launch { clearDownloadQueue.await(onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopDownload(chapter: Chapter) {
|
fun stopDownload(chapter: Chapter) {
|
||||||
scope.launch { stopChapterDownload.await(chapter) }
|
scope.launch { stopChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun moveToBottom(chapter: Chapter) {
|
fun moveToBottom(chapter: Chapter) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
stopChapterDownload.await(chapter)
|
stopChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) })
|
||||||
queueChapterDownload.await(chapter)
|
queueChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private suspend fun getExtensions() {
|
private suspend fun getExtensions() {
|
||||||
extensionList.value = getExtensionList.await().orEmpty()
|
extensionList.value = getExtensionList.await(onError = { toast(it.message.orEmpty()) }).orEmpty()
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
.also { file ->
|
.also { file ->
|
||||||
source.saveTo(file)
|
source.saveTo(file)
|
||||||
}
|
}
|
||||||
installExtensionFile.await(file)
|
installExtensionFile.await(file, onError = { toast(it.message.orEmpty()) })
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
log.warn(e) { "Error creating apk file" }
|
log.warn(e) { "Error creating apk file" }
|
||||||
// todo toast if error
|
// todo toast if error
|
||||||
@@ -107,7 +107,7 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
fun install(extension: Extension) {
|
fun install(extension: Extension) {
|
||||||
log.info { "Install clicked" }
|
log.info { "Install clicked" }
|
||||||
scope.launch {
|
scope.launch {
|
||||||
installExtension.await(extension)
|
installExtension.await(extension, onError = { toast(it.message.orEmpty()) })
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
fun update(extension: Extension) {
|
fun update(extension: Extension) {
|
||||||
log.info { "Update clicked" }
|
log.info { "Update clicked" }
|
||||||
scope.launch {
|
scope.launch {
|
||||||
updateExtension.await(extension)
|
updateExtension.await(extension, onError = { toast(it.message.orEmpty()) })
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ class ExtensionsScreenViewModel @Inject constructor(
|
|||||||
fun uninstall(extension: Extension) {
|
fun uninstall(extension: Extension) {
|
||||||
log.info { "Uninstall clicked" }
|
log.info { "Uninstall clicked" }
|
||||||
scope.launch {
|
scope.launch {
|
||||||
uninstallExtension.await(extension)
|
uninstallExtension.await(extension, onError = { toast(it.message.orEmpty()) })
|
||||||
getExtensions()
|
getExtensions()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun removeManga(mangaId: Long) {
|
fun removeManga(mangaId: Long) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
removeMangaFromLibrary.await(mangaId)
|
removeMangaFromLibrary.await(mangaId, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -297,11 +297,11 @@ class LibraryScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun updateLibrary() {
|
fun updateLibrary() {
|
||||||
scope.launch { updateLibrary.await() }
|
scope.launch { updateLibrary.await(onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun updateCategory(category: Category) {
|
fun updateCategory(category: Category) {
|
||||||
scope.launch { updateCategory.await(category) }
|
scope.launch { updateCategory.await(category, onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ package ca.gosyer.jui.ui.main
|
|||||||
import ca.gosyer.jui.domain.ui.service.UiPreferences
|
import ca.gosyer.jui.domain.ui.service.UiPreferences
|
||||||
import ca.gosyer.jui.i18n.MR
|
import ca.gosyer.jui.i18n.MR
|
||||||
import ca.gosyer.jui.uicore.vm.ContextWrapper
|
import ca.gosyer.jui.uicore.vm.ContextWrapper
|
||||||
import ca.gosyer.jui.uicore.vm.Length
|
|
||||||
import ca.gosyer.jui.uicore.vm.ViewModel
|
import ca.gosyer.jui.uicore.vm.ViewModel
|
||||||
import kotlinx.coroutines.MainScope
|
import kotlinx.coroutines.MainScope
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
@@ -30,6 +29,6 @@ class MainViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun confirmExitToast() {
|
fun confirmExitToast() {
|
||||||
toast(MR.strings.confirm_exit_toast.toPlatformString(), Length.SHORT)
|
toast(MR.strings.confirm_exit_toast.toPlatformString())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,13 +49,13 @@ class AboutViewModel @Inject constructor(
|
|||||||
|
|
||||||
private fun getAbout() {
|
private fun getAbout() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_aboutHolder.value = aboutServer.await()
|
_aboutHolder.value = aboutServer.await(onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun checkForUpdates() {
|
fun checkForUpdates() {
|
||||||
scope.launch {
|
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)
|
is Update.UpdateFound -> _updates.emit(update)
|
||||||
else -> Unit
|
else -> Unit
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,7 +84,10 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
|
|
||||||
val categories = getCategories.asFlow(true)
|
val categories = getCategories.asFlow(true)
|
||||||
.map { it.toImmutableList() }
|
.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())
|
.stateIn(scope, SharingStarted.Eagerly, persistentListOf())
|
||||||
|
|
||||||
private val _mangaCategories = MutableStateFlow<ImmutableList<Category>>(persistentListOf())
|
private val _mangaCategories = MutableStateFlow<ImmutableList<Category>>(persistentListOf())
|
||||||
@@ -169,14 +172,12 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
private suspend fun refreshChaptersAsync(mangaId: Long, refresh: Boolean = false) = withIOContext {
|
private suspend fun refreshChaptersAsync(mangaId: Long, refresh: Boolean = false) = withIOContext {
|
||||||
async {
|
async {
|
||||||
val chapters = if (refresh) {
|
val chapters = if (refresh) {
|
||||||
refreshChapters.await(mangaId)
|
refreshChapters.await(mangaId, onError = { toast(it.message.orEmpty()) })
|
||||||
} else {
|
} else {
|
||||||
getChapters.await(mangaId)
|
getChapters.await(mangaId, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
if (chapters != null) {
|
if (chapters != null) {
|
||||||
_chapters.value = chapters.toDownloadChapters()
|
_chapters.value = chapters.toDownloadChapters()
|
||||||
} else {
|
|
||||||
// TODO: 2022-07-01 Error toast
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -185,7 +186,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
scope.launch {
|
scope.launch {
|
||||||
manga.value?.let { manga ->
|
manga.value?.let { manga ->
|
||||||
if (manga.inLibrary) {
|
if (manga.inLibrary) {
|
||||||
removeMangaFromLibrary.await(manga)
|
removeMangaFromLibrary.await(manga, onError = { toast(it.message.orEmpty()) })
|
||||||
refreshMangaAsync(manga.id).await()
|
refreshMangaAsync(manga.id).await()
|
||||||
} else {
|
} else {
|
||||||
if (categories.value.isEmpty()) {
|
if (categories.value.isEmpty()) {
|
||||||
@@ -203,13 +204,13 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
manga.value?.let { manga ->
|
manga.value?.let { manga ->
|
||||||
if (manga.inLibrary) {
|
if (manga.inLibrary) {
|
||||||
oldCategories.filterNot { it in categories }.forEach {
|
oldCategories.filterNot { it in categories }.forEach {
|
||||||
removeMangaFromCategory.await(manga, it)
|
removeMangaFromCategory.await(manga, it, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addMangaToLibrary.await(manga)
|
addMangaToLibrary.await(manga, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
categories.filterNot { it in oldCategories }.forEach {
|
categories.filterNot { it in oldCategories }.forEach {
|
||||||
addMangaToCategory.await(manga, it)
|
addMangaToCategory.await(manga, it, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
refreshMangaAsync(manga.id).await()
|
refreshMangaAsync(manga.id).await()
|
||||||
}
|
}
|
||||||
@@ -222,7 +223,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
val chapter = findChapter(index) ?: return
|
val chapter = findChapter(index) ?: return
|
||||||
scope.launch {
|
scope.launch {
|
||||||
manga.value?.let { manga ->
|
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()
|
refreshChaptersAsync(manga.id).await()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -232,7 +233,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
val chapter = findChapter(index) ?: return
|
val chapter = findChapter(index) ?: return
|
||||||
scope.launch {
|
scope.launch {
|
||||||
manga.value?.let { manga ->
|
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()
|
refreshChaptersAsync(manga.id).await()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -241,7 +242,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
fun markPreviousRead(index: Int) {
|
fun markPreviousRead(index: Int) {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
manga.value?.let { manga ->
|
manga.value?.let { manga ->
|
||||||
updateChapterMarkPreviousRead.await(manga, index)
|
updateChapterMarkPreviousRead.await(manga, index, onError = { toast(it.message.orEmpty()) })
|
||||||
refreshChaptersAsync(manga.id).await()
|
refreshChaptersAsync(manga.id).await()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -249,7 +250,7 @@ class MangaScreenViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun downloadChapter(index: Int) {
|
fun downloadChapter(index: Int) {
|
||||||
manga.value?.let { manga ->
|
manga.value?.let { manga ->
|
||||||
scope.launch { queueChapterDownload.await(manga, index) }
|
scope.launch { queueChapterDownload.await(manga, index, onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
fun setMangaReaderMode(mode: String) {
|
fun setMangaReaderMode(mode: String) {
|
||||||
scope.launchDefault {
|
scope.launchDefault {
|
||||||
_manga.value?.let {
|
_manga.value?.let {
|
||||||
updateMangaMeta.await(it, mode)
|
updateMangaMeta.await(it, mode, onError = { toast(it.message.orEmpty()) })
|
||||||
}
|
}
|
||||||
initManga(params.mangaId)
|
initManga(params.mangaId)
|
||||||
}
|
}
|
||||||
@@ -307,14 +307,14 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun markChapterRead(chapter: ReaderChapter) {
|
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)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
fun sendProgress(chapter: Chapter? = this.chapter.value?.chapter, lastPageRead: Int = currentPage.value) {
|
fun sendProgress(chapter: Chapter? = this.chapter.value?.chapter, lastPageRead: Int = currentPage.value) {
|
||||||
chapter ?: return
|
chapter ?: return
|
||||||
if (chapter.read) 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) {
|
fun updateLastPageReadOffset(offset: Int) {
|
||||||
@@ -323,7 +323,7 @@ class ReaderMenuViewModel @Inject constructor(
|
|||||||
|
|
||||||
@OptIn(DelicateCoroutinesApi::class)
|
@OptIn(DelicateCoroutinesApi::class)
|
||||||
private fun updateLastPageReadOffset(chapter: Chapter, offset: Int) {
|
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() {
|
override fun onDispose() {
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Error importing backup" }
|
log.warn(it) { "Error importing backup" }
|
||||||
_restoreStatus.value = Status.Error
|
_restoreStatus.value = Status.Error
|
||||||
}
|
}
|
||||||
@@ -181,6 +182,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
_restoreStatus.value = Status.Success
|
_restoreStatus.value = Status.Success
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Error importing backup" }
|
log.warn(it) { "Error importing backup" }
|
||||||
_restoreStatus.value = Status.Error
|
_restoreStatus.value = Status.Error
|
||||||
}
|
}
|
||||||
@@ -228,6 +230,7 @@ class SettingsBackupViewModel @Inject constructor(
|
|||||||
_createFlow.emit(filename)
|
_createFlow.emit(filename)
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Error exporting backup" }
|
log.warn(it) { "Error exporting backup" }
|
||||||
_creatingStatus.value = Status.Error
|
_creatingStatus.value = Status.Error
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class SettingsLibraryViewModel @Inject constructor(
|
|||||||
|
|
||||||
fun refreshCategoryCount() {
|
fun refreshCategoryCount() {
|
||||||
scope.launch {
|
scope.launch {
|
||||||
_categories.value = getCategories.await(true)?.size ?: 0
|
_categories.value = getCategories.await(true, onError = { toast(it.message.orEmpty()) })?.size ?: 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -76,10 +76,11 @@ class SourceFiltersViewModel(
|
|||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.onEach {
|
.onEach {
|
||||||
setSourceFilter.await(
|
setSourceFilter.await(
|
||||||
sourceId,
|
sourceId = sourceId,
|
||||||
filter.index,
|
filterIndex = filter.index,
|
||||||
childFilter.index,
|
childFilterIndex = childFilter.index,
|
||||||
it
|
filter = it,
|
||||||
|
onError = { toast(it.message.orEmpty()) }
|
||||||
)
|
)
|
||||||
getFilters()
|
getFilters()
|
||||||
}
|
}
|
||||||
@@ -89,9 +90,10 @@ class SourceFiltersViewModel(
|
|||||||
filter.state.drop(1).filterNotNull()
|
filter.state.drop(1).filterNotNull()
|
||||||
.onEach {
|
.onEach {
|
||||||
setSourceFilter.await(
|
setSourceFilter.await(
|
||||||
sourceId,
|
sourceId = sourceId,
|
||||||
filter.index,
|
filterIndex = filter.index,
|
||||||
it
|
filter = it,
|
||||||
|
onError = { toast(it.message.orEmpty()) }
|
||||||
)
|
)
|
||||||
getFilters()
|
getFilters()
|
||||||
}
|
}
|
||||||
@@ -117,6 +119,7 @@ class SourceFiltersViewModel(
|
|||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Error getting filters" }
|
log.warn(it) { "Error getting filters" }
|
||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,7 @@ class GlobalSearchViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Error getting sources" }
|
log.warn(it) { "Error getting sources" }
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ class SourceHomeScreenViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Error getting sources" }
|
log.warn(it) { "Error getting sources" }
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ class SourceSettingsScreenViewModel @Inject constructor(
|
|||||||
setting.state.drop(1)
|
setting.state.drop(1)
|
||||||
.filterNotNull()
|
.filterNotNull()
|
||||||
.onEach {
|
.onEach {
|
||||||
setSourceSetting.await(params.sourceId, setting.index, it)
|
setSourceSetting.await(
|
||||||
|
sourceId = params.sourceId,
|
||||||
|
settingIndex = setting.index,
|
||||||
|
setting = it,
|
||||||
|
onError = { toast(it.message.orEmpty()) })
|
||||||
getSourceSettings()
|
getSourceSettings()
|
||||||
}
|
}
|
||||||
.launchIn(this)
|
.launchIn(this)
|
||||||
@@ -63,6 +67,7 @@ class SourceSettingsScreenViewModel @Inject constructor(
|
|||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Error setting source setting" }
|
log.warn(it) { "Error setting source setting" }
|
||||||
_loading.value = false
|
_loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,7 @@ class UpdatesScreenViewModel @Inject constructor(
|
|||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
}
|
}
|
||||||
.catch {
|
.catch {
|
||||||
|
toast(it.message.orEmpty())
|
||||||
log.warn(it) { "Failed to get updates for page $page" }
|
log.warn(it) { "Failed to get updates for page $page" }
|
||||||
if (page > 1) {
|
if (page > 1) {
|
||||||
currentPage.value = page - 1
|
currentPage.value = page - 1
|
||||||
@@ -131,7 +132,7 @@ class UpdatesScreenViewModel @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun downloadChapter(chapter: Chapter) {
|
fun downloadChapter(chapter: Chapter) {
|
||||||
scope.launch { queueChapterDownload.await(chapter) }
|
scope.launch { queueChapterDownload.await(chapter, onError = { toast(it.message.orEmpty()) }) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun deleteDownloadedChapter(chapter: Chapter) {
|
fun deleteDownloadedChapter(chapter: Chapter) {
|
||||||
|
|||||||
Reference in New Issue
Block a user