Reader: Save reading progress with SQLDelight (#7185)

* Use SQLDelight in reader to update history

* Move chapter progress to sqldelight

* Review Changes

Co-Authored-By: inorichi <len@kanade.eu>

* Review Changes 2

Co-authored-by: FourTOne5 <59261191+FourTOne5@users.noreply.github.com>
Co-authored-by: inorichi <len@kanade.eu>
This commit is contained in:
AntsyLich
2022-05-28 19:09:27 +06:00
committed by GitHub
parent 6b14f38cfa
commit 809da49301
22 changed files with 309 additions and 67 deletions

View File

@@ -0,0 +1,13 @@
package eu.kanade.domain.history.interactor
import eu.kanade.domain.history.model.HistoryUpdate
import eu.kanade.domain.history.repository.HistoryRepository
class UpsertHistory(
private val historyRepository: HistoryRepository,
) {
suspend fun await(historyUpdate: HistoryUpdate) {
historyRepository.upsertHistory(historyUpdate)
}
}

View File

@@ -3,7 +3,8 @@ package eu.kanade.domain.history.model
import java.util.Date
data class History(
val id: Long?,
val id: Long,
val chapterId: Long,
val readAt: Date?,
val readDuration: Long,
)

View File

@@ -0,0 +1,9 @@
package eu.kanade.domain.history.model
import java.util.Date
data class HistoryUpdate(
val chapterId: Long,
val readAt: Date,
val sessionReadDuration: Long,
)

View File

@@ -10,4 +10,5 @@ data class HistoryWithRelations(
val thumbnailUrl: String,
val chapterNumber: Float,
val readAt: Date?,
val readDuration: Long,
)

View File

@@ -2,6 +2,7 @@ package eu.kanade.domain.history.repository
import androidx.paging.PagingSource
import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.history.model.HistoryUpdate
import eu.kanade.domain.history.model.HistoryWithRelations
interface HistoryRepository {
@@ -15,4 +16,6 @@ interface HistoryRepository {
suspend fun resetHistoryByMangaId(mangaId: Long)
suspend fun deleteAllHistory(): Boolean
suspend fun upsertHistory(historyUpdate: HistoryUpdate)
}