[MangaDex] Speed up large chapters list loading (hotfix)

pull/46/head
Koitharu 4 years ago
parent baf6234a2a
commit e2308214a7
No known key found for this signature in database
GPG Key ID: 8E861F8CE6E7CE27

@ -247,7 +247,7 @@ internal class MangaDexParser(override val context: MangaLoaderContext) : MangaP
val json = context.httpGet(url).parseJson()
if (json.getString("result") == "ok") {
return Chapters(
data = json.optJSONArray("data")?.filterIsInstance<JSONObject>().orEmpty(),
data = json.optJSONArray("data")?.toJSONList().orEmpty(),
total = json.getInt("total"),
)
} else {

@ -137,3 +137,7 @@ fun JSONArray?.isNullOrEmpty(): Boolean {
return this == null || this.length() == 0
}
fun JSONArray.toJSONList(): List<JSONObject> {
return List(length()) { i -> getJSONObject(i) }
}
Loading…
Cancel
Save