Improve history migration
This commit is contained in:
parent
4212d155ce
commit
b26749d61c
@ -344,9 +344,7 @@ class MigrationListScreenModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateChapter.awaitAll(chapterUpdates)
|
updateChapter.awaitAll(chapterUpdates)
|
||||||
historyUpdates.forEach {
|
upsertHistory.awaitAll(historyUpdates)
|
||||||
upsertHistory.await(it)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// Update categories
|
// Update categories
|
||||||
if (MigrationFlags.hasCategories(flags)) {
|
if (MigrationFlags.hasCategories(flags)) {
|
||||||
|
@ -70,6 +70,22 @@ class HistoryRepositoryImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SY -->
|
// 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> {
|
override suspend fun getByMangaId(mangaId: Long): List<History> {
|
||||||
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, historyMapper) }
|
return handler.awaitList { historyQueries.getHistoryByMangaId(mangaId, historyMapper) }
|
||||||
}
|
}
|
||||||
|
@ -10,4 +10,10 @@ class UpsertHistory(
|
|||||||
suspend fun await(historyUpdate: HistoryUpdate) {
|
suspend fun await(historyUpdate: HistoryUpdate) {
|
||||||
historyRepository.upsertHistory(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)
|
suspend fun upsertHistory(historyUpdate: HistoryUpdate)
|
||||||
|
|
||||||
// SY -->
|
// SY -->
|
||||||
|
suspend fun upsertHistory(historyUpdates: List<HistoryUpdate>)
|
||||||
|
|
||||||
suspend fun getByMangaId(mangaId: Long): List<History>
|
suspend fun getByMangaId(mangaId: Long): List<History>
|
||||||
// SY <--
|
// SY <--
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user