mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 19:31:48 +01:00
Show error toast when extensions list fails to load
This commit is contained in:
parent
06c3f57f62
commit
022c0746c0
@ -15,6 +15,7 @@ import eu.kanade.tachiyomi.extension.util.ExtensionLoader
|
||||
import eu.kanade.tachiyomi.source.Source
|
||||
import eu.kanade.tachiyomi.source.SourceManager
|
||||
import eu.kanade.tachiyomi.util.lang.launchNow
|
||||
import eu.kanade.tachiyomi.util.system.toast
|
||||
import kotlinx.coroutines.async
|
||||
import rx.Observable
|
||||
import uy.kohesive.injekt.Injekt
|
||||
@ -160,6 +161,7 @@ class ExtensionManager(
|
||||
val extensions: List<Extension.Available> = try {
|
||||
api.findExtensions()
|
||||
} catch (e: Exception) {
|
||||
context.toast(e.message)
|
||||
emptyList()
|
||||
}
|
||||
|
||||
|
@ -31,21 +31,21 @@ internal class ExtensionGithubApi {
|
||||
val call = GET(EXT_URL)
|
||||
|
||||
return withContext(Dispatchers.IO) {
|
||||
parseResponse(network.client.newCall(call).await())
|
||||
val response = network.client.newCall(call).await()
|
||||
if (response.isSuccessful) {
|
||||
parseResponse(response)
|
||||
} else {
|
||||
response.close()
|
||||
throw Exception("Failed to get extensions")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun checkForUpdates(context: Context): List<Extension.Installed> {
|
||||
val call = GET(EXT_URL)
|
||||
|
||||
return withContext(Dispatchers.IO) {
|
||||
val response = network.client.newCall(call).await()
|
||||
val extensions = findExtensions()
|
||||
|
||||
preferences.lastExtCheck().set(Date().time)
|
||||
|
||||
if (response.isSuccessful) {
|
||||
val extensions = parseResponse(response)
|
||||
|
||||
val installedExtensions = ExtensionLoader.loadExtensions(context)
|
||||
.filterIsInstance<LoadResult.Success>()
|
||||
.map { it.extension }
|
||||
@ -61,12 +61,7 @@ internal class ExtensionGithubApi {
|
||||
}
|
||||
}
|
||||
|
||||
extensionsWithUpdate
|
||||
} else {
|
||||
response.close()
|
||||
throw Exception("Failed to get extensions")
|
||||
}
|
||||
}
|
||||
return extensionsWithUpdate
|
||||
}
|
||||
|
||||
private fun parseResponse(response: Response): List<Extension.Available> {
|
||||
|
Loading…
Reference in New Issue
Block a user