Move when fetching history is done in details page

This commit is contained in:
Jays2Kings 2023-09-28 21:16:17 -07:00
parent a86e7979f7
commit 55ae1f32f2

View file

@ -136,6 +136,7 @@ class MangaDetailsPresenter(
} else { } else {
runBlocking { getChapters() } runBlocking { getChapters() }
controller.updateChapters(this.chapters) controller.updateChapters(this.chapters)
getHistory()
} }
presenterScope.launch { presenterScope.launch {
setTrackItems() setTrackItems()
@ -153,6 +154,7 @@ class MangaDetailsPresenter(
getChapters() getChapters()
if (andTracking) fetchTracks() if (andTracking) fetchTracks()
withContext(Dispatchers.Main) { view?.updateChapters(chapters) } withContext(Dispatchers.Main) { view?.updateChapters(chapters) }
getHistory()
} }
} }
@ -170,8 +172,11 @@ class MangaDetailsPresenter(
// Store the last emission // Store the last emission
allChapters = chapters allChapters = chapters
this.chapters = applyChapterFilters(chapters) this.chapters = applyChapterFilters(chapters)
}
private fun getHistory() {
presenterScope.launchIO { presenterScope.launchIO {
allHistory = manga.id?.let { db.getHistoryByMangaId(it).executeOnIO() }.orEmpty() allHistory = manga.id?.let { db.getHistoryByMangaId(it).executeAsBlocking() }.orEmpty()
} }
} }
@ -428,6 +433,7 @@ class MangaDetailsPresenter(
) )
} }
} }
getHistory()
} }
} }
@ -453,6 +459,7 @@ class MangaDetailsPresenter(
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
view?.updateChapters(this@MangaDetailsPresenter.chapters) view?.updateChapters(this@MangaDetailsPresenter.chapters)
} }
getHistory()
} catch (e: java.lang.Exception) { } catch (e: java.lang.Exception) {
withContext(Dispatchers.Main) { withContext(Dispatchers.Main) {
view?.showError(trimException(e)) view?.showError(trimException(e))