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

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() val json = context.httpGet(url).parseJson()
if (json.getString("result") == "ok") { if (json.getString("result") == "ok") {
return Chapters( return Chapters(
data = json.optJSONArray("data")?.filterIsInstance<JSONObject>().orEmpty(), data = json.optJSONArray("data")?.toJSONList().orEmpty(),
total = json.getInt("total"), total = json.getInt("total"),
) )
} else { } else {

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