Skip to content

Commit

Permalink
Fix issue with chosen titles sometimes reverting
Browse files Browse the repository at this point in the history
  • Loading branch information
julieminer committed Aug 8, 2024
1 parent cc42e88 commit 5f8db60
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ fun ChapterEntity.Companion.from(chapter: Chapter): ChapterEntity {
)
}

fun MangaEntity.Companion.from(manga: Manga): MangaEntity {
fun MangaEntity.Companion.from(manga: Manga, chosenTitle: String?): MangaEntity {
val titles = manga.attributes.getEnglishTitles()
return MangaEntity(
id = manga.id,
mangaTitles = titles,
chosenTitle = titles.last(),
chosenTitle = chosenTitle ?: titles.last(),
mangaCoverId = manga.fileName,
status = manga.attributes.status,
tags = manga.attributes.tags.mapNotNull {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ class MangaRepository(

if (mangaIds.isNotEmpty()) {
val mangaSeries = mangaService.getManga(token, mangaIds.toList())
val manga = mangaSeries.map { MangaEntity.from(it) }

// grab the chosen title from the DB
manga.map { it.copy(chosenTitle = mangaDb.getMangaById(it.id).first()?.chosenTitle) }
val manga = mangaSeries.map {
// grab the chosen title from the DB
MangaEntity.from(it, mangaDb.getMangaById(it.id).first()?.chosenTitle)
}

// insert new series into local db
mangaDb.insertAll(*manga.toTypedArray())
Expand Down

0 comments on commit 5f8db60

Please sign in to comment.