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

This commit is contained in:
2022-08-04 13:32:53 +03:00
parent baf6234a2a
commit e2308214a7
2 changed files with 5 additions and 1 deletions

View File

@@ -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 {

View File

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