From 09a3509d795101f65c13d5936b00df8e15c43315 Mon Sep 17 00:00:00 2001 From: stevenyomi <95685115+stevenyomi@users.noreply.github.com> Date: Sun, 31 Jul 2022 23:18:12 +0800 Subject: [PATCH] Filter out empty genres before saving manga to database (#7655) (cherry picked from commit 4efb736e56dd1e9f6438502dac915467f5b64f03) --- .../java/eu/kanade/tachiyomi/data/database/models/Manga.kt | 5 ----- .../main/java/eu/kanade/tachiyomi/source/model/SManga.kt | 7 ++++++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt index 35efbe1ff..de086bb68 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/database/models/Manga.kt @@ -32,11 +32,6 @@ interface Manga : SManga { return chapter_flags and CHAPTER_SORT_MASK == CHAPTER_SORT_DESC } - fun getGenres(): List? { - if (genre.isNullOrBlank()) return null - return genre?.split(", ")?.map { it.trim() }?.filterNot { it.isBlank() }?.distinct() - } - private fun setChapterFlags(flag: Int, mask: Int) { chapter_flags = chapter_flags and mask.inv() or (flag and mask) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt b/app/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt index 489938aba..a3fad6d8a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/source/model/SManga.kt @@ -23,6 +23,11 @@ interface SManga : Serializable { var initialized: Boolean + fun getGenres(): List? { + if (genre.isNullOrBlank()) return null + return genre?.split(", ")?.map { it.trim() }?.filterNot { it.isBlank() }?.distinct() + } + fun copyFrom(other: SManga) { if (other.author != null) { author = other.author @@ -73,7 +78,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 ?: "", )