mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-29 10:31:49 +01:00
Fix snackbar blocking refreshing state in MangaScreen (#8759)
This commit is contained in:
parent
376bbeb724
commit
c44db54d9f
@ -213,20 +213,19 @@ class MangaInfoScreenModel(
|
||||
* Fetch manga information from source.
|
||||
*/
|
||||
private suspend fun fetchMangaFromSource(manualFetch: Boolean = false) {
|
||||
withIOContext {
|
||||
val state = successState ?: return
|
||||
try {
|
||||
successState?.let {
|
||||
val networkManga = it.source.getMangaDetails(it.manga.toSManga())
|
||||
updateManga.awaitUpdateFromSource(it.manga, networkManga, manualFetch)
|
||||
withIOContext {
|
||||
val networkManga = state.source.getMangaDetails(state.manga.toSManga())
|
||||
updateManga.awaitUpdateFromSource(state.manga, networkManga, manualFetch)
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
withUIContext {
|
||||
// Ignore early hints "errors" that aren't handled by OkHttp
|
||||
if (e !is HttpException || e.code != 103) {
|
||||
snackbarHostState.showSnackbar(message = "${e.message}")
|
||||
if (e is HttpException && e.code == 103) return
|
||||
|
||||
logcat(LogPriority.ERROR, e)
|
||||
}
|
||||
}
|
||||
coroutineScope.launch {
|
||||
snackbarHostState.showSnackbar(message = e.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -524,15 +523,15 @@ class MangaInfoScreenModel(
|
||||
* Requests an updated list of chapters from the source.
|
||||
*/
|
||||
private suspend fun fetchChaptersFromSource(manualFetch: Boolean = false) {
|
||||
withIOContext {
|
||||
val state = successState ?: return
|
||||
try {
|
||||
successState?.let { successState ->
|
||||
val chapters = successState.source.getChapterList(successState.manga.toSManga())
|
||||
withIOContext {
|
||||
val chapters = state.source.getChapterList(state.manga.toSManga())
|
||||
|
||||
val newChapters = syncChaptersWithSource.await(
|
||||
chapters,
|
||||
successState.manga,
|
||||
successState.source,
|
||||
state.manga,
|
||||
state.source,
|
||||
)
|
||||
|
||||
if (manualFetch) {
|
||||
@ -540,14 +539,15 @@ class MangaInfoScreenModel(
|
||||
}
|
||||
}
|
||||
} catch (e: Throwable) {
|
||||
withUIContext {
|
||||
if (e is NoChaptersException) {
|
||||
snackbarHostState.showSnackbar(message = context.getString(R.string.no_chapters_error))
|
||||
val message = if (e is NoChaptersException) {
|
||||
context.getString(R.string.no_chapters_error)
|
||||
} else {
|
||||
snackbarHostState.showSnackbar(message = "${e.message}")
|
||||
logcat(LogPriority.ERROR, e)
|
||||
e.toString()
|
||||
}
|
||||
}
|
||||
|
||||
coroutineScope.launch {
|
||||
snackbarHostState.showSnackbar(message = message)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user