New chapters for manga from deeplinks now have a date fetched saved

This commit is contained in:
Jays2Kings 2021-05-11 15:15:37 -04:00
parent 5727b1541a
commit b3f42659ce

View File

@ -353,8 +353,8 @@ class ReaderPresenter(
true true
} else { } else {
val httpSource = sourceManager.getOrStub(source) as? HttpSource val httpSource = sourceManager.getOrStub(source) as? HttpSource
val host = delegatedSource.domainName val domainName = delegatedSource.domainName
httpSource?.baseUrl?.contains(host) == true httpSource?.baseUrl?.contains(domainName) == true
} }
} }
if (dbChapter?.manga_id != null) { if (dbChapter?.manga_id != null) {
@ -379,13 +379,20 @@ class ReaderPresenter(
this@ReaderPresenter.init(manga, matchingChapterId) this@ReaderPresenter.init(manga, matchingChapterId)
} }
} else { } else {
val chapterId = db.insertChapter(chapter).executeOnIO().insertedId() ?: return val chapterId: Long
if (chapters.isNotEmpty()) { if (chapters.isNotEmpty()) {
syncChaptersWithSource( val newChapters = syncChaptersWithSource(
db, db,
chapters, chapters,
manga, manga,
delegatedSource.delegate!! delegatedSource.delegate!!
).first
chapterId = newChapters.find { it.url == chapter.url }?.id
?: error(preferences.context.getString(R.string.chapter_not_found))
} else {
chapter.date_fetch = Date().time
chapterId = db.insertChapter(chapter).executeOnIO().insertedId() ?: error(
preferences.context.getString(R.string.unknown_error)
) )
} }
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {