mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-14 04:58:56 +01:00
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:
@@ -12,7 +12,7 @@ import eu.kanade.domain.extension.interactor.GetExtensionUpdates
|
||||
import eu.kanade.domain.extension.interactor.GetExtensions
|
||||
import eu.kanade.domain.history.interactor.DeleteHistoryTable
|
||||
import eu.kanade.domain.history.interactor.GetHistory
|
||||
import eu.kanade.domain.history.interactor.GetNextChapterForManga
|
||||
import eu.kanade.domain.history.interactor.GetNextChapter
|
||||
import eu.kanade.domain.history.interactor.RemoveHistoryById
|
||||
import eu.kanade.domain.history.interactor.RemoveHistoryByMangaId
|
||||
import eu.kanade.domain.history.interactor.UpsertHistory
|
||||
@@ -39,7 +39,7 @@ class DomainModule : InjektModule {
|
||||
override fun InjektRegistrar.registerInjectables() {
|
||||
addSingletonFactory<MangaRepository> { MangaRepositoryImpl(get()) }
|
||||
addFactory { GetFavoritesBySourceId(get()) }
|
||||
addFactory { GetNextChapterForManga(get()) }
|
||||
addFactory { GetNextChapter(get()) }
|
||||
addFactory { ResetViewerFlags(get()) }
|
||||
|
||||
addSingletonFactory<ChapterRepository> { ChapterRepositoryImpl(get()) }
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user