feat: add read last read chapter shortcut (#7230)

Supersedes #6861

Co-authored-by: Pierre-Monier <65488471+Pierre-Monier@users.noreply.github.com>

Co-authored-by: Pierre-Monier <65488471+Pierre-Monier@users.noreply.github.com>
This commit is contained in:
Andreas
2022-06-01 04:55:58 +02:00
committed by GitHub
parent 11c61d42dc
commit 4560033e66
9 changed files with 61 additions and 9 deletions

View File

@@ -3,11 +3,16 @@ package eu.kanade.domain.history.interactor
import eu.kanade.domain.chapter.model.Chapter
import eu.kanade.domain.history.repository.HistoryRepository
class GetNextChapterForManga(
class GetNextChapter(
private val repository: HistoryRepository,
) {
suspend fun await(mangaId: Long, chapterId: Long): Chapter? {
return repository.getNextChapterForManga(mangaId, chapterId)
return repository.getNextChapter(mangaId, chapterId)
}
suspend fun await(): Chapter? {
val history = repository.getLastHistory() ?: return null
return repository.getNextChapter(history.mangaId, history.chapterId)
}
}

View File

@@ -9,7 +9,9 @@ interface HistoryRepository {
fun getHistory(query: String): PagingSource<Long, HistoryWithRelations>
suspend fun getNextChapterForManga(mangaId: Long, chapterId: Long): Chapter?
suspend fun getLastHistory(): HistoryWithRelations?
suspend fun getNextChapter(mangaId: Long, chapterId: Long): Chapter?
suspend fun resetHistory(historyId: Long)