Skip to content

Commit

Permalink
fix: Title is only lateinit on SMangaImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
null2264 committed Jan 13, 2025
1 parent 915ce20 commit d6ffbe1
Showing 1 changed file with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -278,18 +278,24 @@ open class GlobalSearchPresenter(
protected open suspend fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga? {
var localManga = getManga.awaitByUrlAndSource(sManga.url, sourceId)
if (localManga == null) {
if (!sManga::title.isInitialized) return null

val newManga = Manga.create(sManga.url, sManga.title, sourceId)
val newManga =
try {
Manga.create(sManga.url, sManga.title, sourceId)
} catch (_: UninitializedPropertyAccessException) {
return null
}
newManga.copyFrom(sManga)
newManga.id = insertManga.await(newManga)
localManga = newManga
} else if (!localManga.favorite) {
if (!sManga::title.isInitialized) return localManga

// if the manga isn't a favorite, set its display title from source
// if it later becomes a favorite, updated title will go to db
localManga.title = sManga.title
localManga.title =
try {
sManga.title
} catch (_: UninitializedPropertyAccessException) {
return localManga
}
}
return localManga
}
Expand Down

0 comments on commit d6ffbe1

Please sign in to comment.