Cleanup custom info, fix custom genre not saving if you dont edit it
This commit is contained in:
parent
0a4fcb480d
commit
a17c4c151f
@ -14,16 +14,12 @@ class CustomMangaManager(val context: Context) {
|
||||
|
||||
private val editJson = File(context.getExternalFilesDir(null), "edits.json")
|
||||
|
||||
private var customMangaMap = mutableMapOf<Long, Manga>()
|
||||
|
||||
init {
|
||||
fetchCustomData()
|
||||
}
|
||||
private val customMangaMap = fetchCustomData()
|
||||
|
||||
fun getManga(manga: Manga): Manga? = customMangaMap[manga.id]
|
||||
|
||||
private fun fetchCustomData() {
|
||||
if (!editJson.exists() || !editJson.isFile) return
|
||||
private fun fetchCustomData(): MutableMap<Long, Manga> {
|
||||
if (!editJson.exists() || !editJson.isFile) return mutableMapOf()
|
||||
|
||||
val json = try {
|
||||
Json.decodeFromString<MangaList>(
|
||||
@ -31,10 +27,10 @@ class CustomMangaManager(val context: Context) {
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
} ?: return
|
||||
} ?: return mutableMapOf()
|
||||
|
||||
val mangasJson = json.mangas ?: return
|
||||
customMangaMap = mangasJson.mapNotNull { mangaJson ->
|
||||
val mangasJson = json.mangas ?: return mutableMapOf()
|
||||
return mangasJson.mapNotNull { mangaJson ->
|
||||
val id = mangaJson.id ?: return@mapNotNull null
|
||||
val manga = MangaImpl().apply {
|
||||
this.id = id
|
||||
|
@ -317,7 +317,7 @@ class MangaPresenter(
|
||||
LocalSource(downloadManager.context).updateMangaInfo(manga)
|
||||
db.updateMangaInfo(manga).executeAsBlocking()
|
||||
} else {
|
||||
val genre = if (!tags.isNullOrEmpty() && tags.joinToString() != manga.genre) {
|
||||
val genre = if (!tags.isNullOrEmpty() && tags.joinToString() != manga.originalGenre) {
|
||||
tags
|
||||
} else {
|
||||
null
|
||||
|
Loading…
x
Reference in New Issue
Block a user