From 5474eddf84a2e706da114d97dc6c732fd6a46068 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Sun, 15 Aug 2021 02:41:23 +0430 Subject: [PATCH] fix some inconsitencies --- .../anime/impl/extension/Extension.kt | 2 +- .../extension/github/ExtensionGithubApi.kt | 2 +- .../suwayomi/tachidesk/manga/impl/Chapter.kt | 31 ++++++++++++------- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/Extension.kt b/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/Extension.kt index 8155ae6c..a4e62408 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/Extension.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/Extension.kt @@ -138,7 +138,7 @@ object Extension { else -> "all" } - val extensionName = packageInfo.applicationInfo.nonLocalizedLabel.toString().substringAfter("Tachiyomi: ") + val extensionName = packageInfo.applicationInfo.nonLocalizedLabel.toString().substringAfter("Aniyomi: ") // update extension info transaction { diff --git a/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/github/ExtensionGithubApi.kt b/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/github/ExtensionGithubApi.kt index bc30373b..9c017cd4 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/github/ExtensionGithubApi.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/anime/impl/extension/github/ExtensionGithubApi.kt @@ -32,7 +32,7 @@ object ExtensionGithubApi { libVersion in LIB_VERSION_MIN..LIB_VERSION_MAX } .map { element -> - val name = element["name"].string.substringAfter("Tachiyomi: ") + val name = element["name"].string.substringAfter("Aniyomi: ") val pkgName = element["pkg"].string val apkName = element["apk"].string val versionName = element["version"].string diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt index 48f6f9cb..c5653818 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt @@ -30,8 +30,8 @@ import java.time.Instant object Chapter { /** get chapter list when showing a manga */ - suspend fun getChapterList(mangaId: Int, onlineFetch: Boolean?): List { - return if (onlineFetch == true) { + suspend fun getChapterList(mangaId: Int, onlineFetch: Boolean = false): List { + return if (onlineFetch) { getSourceChapters(mangaId) } else { transaction { @@ -40,10 +40,7 @@ object Chapter { ChapterTable.toDataClass(it) } }.ifEmpty { - // If it was explicitly set to offline dont grab chapters - if (onlineFetch == null) { - getSourceChapters(mangaId) - } else emptyList() + getSourceChapters(mangaId) } } } @@ -163,7 +160,10 @@ object Chapter { // update page list for this chapter transaction { pageList.forEach { page -> - val pageEntry = transaction { PageTable.select { (PageTable.chapter eq chapterId) and (PageTable.index eq page.index) }.firstOrNull() } + val pageEntry = transaction { + PageTable.select { (PageTable.chapter eq chapterId) and (PageTable.index eq page.index) } + .firstOrNull() + } if (pageEntry == null) { PageTable.insert { it[index] = page.index @@ -210,7 +210,14 @@ object Chapter { } } - fun modifyChapter(mangaId: Int, chapterIndex: Int, isRead: Boolean?, isBookmarked: Boolean?, markPrevRead: Boolean?, lastPageRead: Int?) { + fun modifyChapter( + mangaId: Int, + chapterIndex: Int, + isRead: Boolean?, + isBookmarked: Boolean?, + markPrevRead: Boolean?, + lastPageRead: Int? + ) { transaction { if (listOf(isRead, isBookmarked, lastPageRead).any { it != null }) { ChapterTable.update({ (ChapterTable.manga eq mangaId) and (ChapterTable.chapterIndex eq chapterIndex) }) { update -> @@ -244,9 +251,11 @@ object Chapter { fun modifyChapterMeta(mangaId: Int, chapterIndex: Int, key: String, value: String) { transaction { - val chapter = ChapterTable.select { (ChapterTable.manga eq mangaId) and (ChapterTable.chapterIndex eq chapterIndex) } - .first()[ChapterTable.id] - val meta = transaction { ChapterMetaTable.select { (ChapterMetaTable.ref eq chapter) and (ChapterMetaTable.key eq key) } }.firstOrNull() + val chapter = + ChapterTable.select { (ChapterTable.manga eq mangaId) and (ChapterTable.chapterIndex eq chapterIndex) } + .first()[ChapterTable.id] + val meta = + transaction { ChapterMetaTable.select { (ChapterMetaTable.ref eq chapter) and (ChapterMetaTable.key eq key) } }.firstOrNull() if (meta == null) { ChapterMetaTable.insert { it[ChapterMetaTable.key] = key