From eb9b9b9aee67bedaaa277f8f83c82ea23e1724fd Mon Sep 17 00:00:00 2001 From: DokterKaj <54882101+DokterKaj@users.noreply.github.com> Date: Wed, 9 Apr 2025 22:50:01 +0800 Subject: [PATCH] DeviantArt: Order chapter list chronologically instead of by source (#8407) Order chapter list chronologically instead of by source --- src/all/deviantart/build.gradle | 2 +- .../extension/all/deviantart/DeviantArt.kt | 25 ++++++++----------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/src/all/deviantart/build.gradle b/src/all/deviantart/build.gradle index b775377c9..b580099a4 100644 --- a/src/all/deviantart/build.gradle +++ b/src/all/deviantart/build.gradle @@ -1,7 +1,7 @@ ext { extName = 'DeviantArt' extClass = '.DeviantArt' - extVersionCode = 7 + extVersionCode = 8 isNsfw = true } diff --git a/src/all/deviantart/src/eu/kanade/tachiyomi/extension/all/deviantart/DeviantArt.kt b/src/all/deviantart/src/eu/kanade/tachiyomi/extension/all/deviantart/DeviantArt.kt index 228549b9a..bd760f5f5 100644 --- a/src/all/deviantart/src/eu/kanade/tachiyomi/extension/all/deviantart/DeviantArt.kt +++ b/src/all/deviantart/src/eu/kanade/tachiyomi/extension/all/deviantart/DeviantArt.kt @@ -134,12 +134,11 @@ class DeviantArt : HttpSource(), ConfigurableSource { nextUrl = newDocument.selectFirst("[rel=next]")?.absUrl("href") } - return chapterList.toList().also(::indexChapterList) + return chapterList.also(::orderChapterList).toList() } private fun parseToChapterList(document: Document): List { - val items = document.select("item") - return items.map { + return document.select("item").map { SChapter.create().apply { setUrlWithoutDomain(it.selectFirst("link")!!.text()) name = it.selectFirst("title")!!.text() @@ -149,17 +148,15 @@ class DeviantArt : HttpSource(), ConfigurableSource { } } - private fun indexChapterList(chapterList: List) { - // DeviantArt allows users to arrange galleries arbitrarily so we will - // primitively index the list by checking the first and last dates - if (chapterList.first().date_upload > chapterList.last().date_upload) { - chapterList.forEachIndexed { i, chapter -> - chapter.chapter_number = chapterList.size - i.toFloat() - } - } else { - chapterList.forEachIndexed { i, chapter -> - chapter.chapter_number = i.toFloat() + 1 - } + private fun orderChapterList(chapterList: MutableList) { + // In Mihon's updates tab, chapters are ordered by source instead + // of chapter number, so to avoid updates being shown in reverse, + // disregard source order and order chronologically instead + if (chapterList.first().date_upload < chapterList.last().date_upload) { + chapterList.reverse() + } + chapterList.forEachIndexed { i, chapter -> + chapter.chapter_number = chapterList.size - i.toFloat() } }