Filter out empty genres before saving manga to database (#7655)

(cherry picked from commit 4efb736e56dd1e9f6438502dac915467f5b64f03)

# Conflicts:
#	app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt
#	app/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt
This commit is contained in:
stevenyomi 2022-07-31 23:18:12 +08:00 committed by Jobobby04
parent 4b87831bdd
commit 702fdb054a
2 changed files with 6 additions and 6 deletions

View File

@ -32,11 +32,6 @@ interface Manga : SManga {
return chapter_flags and DomainManga.CHAPTER_SORT_DIR_MASK.toInt() == DomainManga.CHAPTER_SORT_DESC.toInt()
}
fun getGenres(): List<String>? {
if (genre.isNullOrBlank()) return null
return genre?.split(", ")?.map { it.trim() }?.filterNot { it.isBlank() }?.distinct()
}
// SY -->
fun getOriginalGenres(): List<String>? {
return originalGenre?.split(", ")?.map { it.trim() }

View File

@ -29,6 +29,11 @@ interface SManga : Serializable {
var initialized: Boolean
fun getGenres(): List<String>? {
if (genre.isNullOrBlank()) return null
return genre?.split(", ")?.map { it.trim() }?.filterNot { it.isBlank() }?.distinct()
}
// SY -->
val originalTitle: String
get() = (this as? MangaImpl)?.ogTitle ?: title
@ -144,7 +149,7 @@ fun SManga.toMangaInfo(): MangaInfo {
artist = this.artist ?: "",
author = this.author ?: "",
description = this.description ?: "",
genres = this.genre?.split(", ") ?: emptyList(),
genres = this.getGenres() ?: emptyList(),
status = this.status,
cover = this.thumbnail_url ?: "",
)