mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
fix: Fix lateinit error
This commit is contained in:
parent
33fa77d527
commit
9e5d13f261
1 changed files with 6 additions and 2 deletions
|
@ -185,7 +185,7 @@ open class GlobalSearchPresenter(
|
||||||
MangasPage(emptyList(), false)
|
MangasPage(emptyList(), false)
|
||||||
}
|
}
|
||||||
.mangas.take(10)
|
.mangas.take(10)
|
||||||
.map { networkToLocalManga(it, source.id) }
|
.mapNotNull { networkToLocalManga(it, source.id) }
|
||||||
fetchImage(mangas, source)
|
fetchImage(mangas, source)
|
||||||
if (mangas.isNotEmpty() && !loadTime.containsKey(source.id)) {
|
if (mangas.isNotEmpty() && !loadTime.containsKey(source.id)) {
|
||||||
loadTime[source.id] = Date().time
|
loadTime[source.id] = Date().time
|
||||||
|
@ -275,14 +275,18 @@ open class GlobalSearchPresenter(
|
||||||
* @param sManga the manga from the source.
|
* @param sManga the manga from the source.
|
||||||
* @return a manga from the database.
|
* @return a manga from the database.
|
||||||
*/
|
*/
|
||||||
protected open suspend fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga {
|
protected open suspend fun networkToLocalManga(sManga: SManga, sourceId: Long): Manga? {
|
||||||
var localManga = getManga.awaitByUrlAndSource(sManga.url, sourceId)
|
var localManga = getManga.awaitByUrlAndSource(sManga.url, sourceId)
|
||||||
if (localManga == null) {
|
if (localManga == null) {
|
||||||
|
if (!sManga::title.isInitialized) return null
|
||||||
|
|
||||||
val newManga = Manga.create(sManga.url, sManga.title, sourceId)
|
val newManga = Manga.create(sManga.url, sManga.title, sourceId)
|
||||||
newManga.copyFrom(sManga)
|
newManga.copyFrom(sManga)
|
||||||
newManga.id = insertManga.await(newManga)
|
newManga.id = insertManga.await(newManga)
|
||||||
localManga = newManga
|
localManga = newManga
|
||||||
} else if (!localManga.favorite) {
|
} else if (!localManga.favorite) {
|
||||||
|
if (!sManga::title.isInitialized) return localManga
|
||||||
|
|
||||||
// if the manga isn't a favorite, set its display title from source
|
// 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
|
// if it later becomes a favorite, updated title will go to db
|
||||||
localManga.title = sManga.title
|
localManga.title = sManga.title
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue