Improve history migration
This commit is contained in:
parent
4212d155ce
commit
b26749d61c
@ -344,9 +344,7 @@ class MigrationListScreenModel(
|
||||
}
|
||||
|
||||
updateChapter.awaitAll(chapterUpdates)
|
||||
historyUpdates.forEach {
|
||||
upsertHistory.await(it)
|
||||
}
|
||||
upsertHistory.awaitAll(historyUpdates)
|
||||
}
|
||||
// Update categories
|
||||
if (MigrationFlags.hasCategories(flags)) {
|
||||
|
@ -70,6 +70,22 @@ class HistoryRepositoryImpl(
|
||||
}
|
||||
|
||||
// SY -->
|
||||
override suspend fun upsertHistory(historyUpdates: List<HistoryUpdate>) {
|
||||
try {
|
||||
handler.await(true) {
|
||||
historyUpdates.forEach { historyUpdate ->
|
||||
historyQueries.upsert(
|
||||
historyUpdate.chapterId,
|
||||
historyUpdate.readAt,
|
||||
historyUpdate.sessionReadDuration,
|
||||
)
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
logcat(LogPriority.ERROR, throwable = e)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getByMangaId(mangaId: Long): List<History> {
|
||||
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, historyMapper) }
|
||||
}
|
||||
|
@ -10,4 +10,10 @@ class UpsertHistory(
|
||||
suspend fun await(historyUpdate: HistoryUpdate) {
|
||||
historyRepository.upsertHistory(historyUpdate)
|
||||
}
|
||||
|
||||
// SY -->
|
||||
suspend fun awaitAll(historyUpdates: List<HistoryUpdate>) {
|
||||
historyRepository.upsertHistory(historyUpdates)
|
||||
}
|
||||
// SY <--
|
||||
}
|
||||
|
@ -22,6 +22,8 @@ interface HistoryRepository {
|
||||
suspend fun upsertHistory(historyUpdate: HistoryUpdate)
|
||||
|
||||
// SY -->
|
||||
suspend fun upsertHistory(historyUpdates: List<HistoryUpdate>)
|
||||
|
||||
suspend fun getByMangaId(mangaId: Long): List<History>
|
||||
// SY <--
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user