Use ChapterInfo wherever possible

This commit is contained in:
Jobobby04
2022-07-22 15:09:40 -04:00
parent 450aeb5a9d
commit 8ef4a7fbbf
6 changed files with 22 additions and 32 deletions
+5 -5
View File
@@ -3,7 +3,6 @@ package exh.md.utils
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.track.mdlist.MdList
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.SChapter
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.source.online.all.MangaDex
import exh.log.xLogD
@@ -25,6 +24,7 @@ import okhttp3.MediaType.Companion.toMediaType
import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody
import org.jsoup.parser.Parser
import tachiyomi.source.model.ChapterInfo
import tachiyomi.source.model.MangaInfo
import uy.kohesive.injekt.Injekt
import uy.kohesive.injekt.api.get
@@ -233,7 +233,7 @@ class MdUtil {
return scanlators.sorted().joinToString(scanlatorSeparator)
}
fun getMissingChapterCount(chapters: List<SChapter>, mangaStatus: Int): String? {
fun getMissingChapterCount(chapters: List<ChapterInfo>, mangaStatus: Int): String? {
if (mangaStatus == SManga.COMPLETED) return null
val remove0ChaptersFromCount = chapters.distinctBy {
@@ -242,14 +242,14 @@ class MdUtil {
} else {*/
it.name
/*}*/
}.sortedByDescending { it.chapter_number }
}.sortedByDescending { it.number }
remove0ChaptersFromCount.firstOrNull()?.let { chapter ->
val chpNumber = chapter.chapter_number.floor()
val chpNumber = chapter.number.floor()
val allChapters = (1..chpNumber).toMutableSet()
remove0ChaptersFromCount.forEach {
allChapters.remove(it.chapter_number.floor())
allChapters.remove(it.number.floor())
}
if (allChapters.isEmpty()) return null