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:
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
)
|
||||
|
||||
@@ -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,
|
||||
)
|
||||
@@ -10,4 +10,5 @@ data class HistoryWithRelations(
|
||||
val thumbnailUrl: String,
|
||||
val chapterNumber: Float,
|
||||
val readAt: Date?,
|
||||
val readDuration: Long,
|
||||
)
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user