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

@@ -177,6 +177,16 @@ class MainActivity : BaseActivity() {
router.pushController(DownloadController())
}
}
R.id.nav_history -> {
if (router.backstackSize == 1) {
try {
val historyController = router.backstack[0].controller as HistoryController
historyController.resumeLastChapterRead()
} catch (e: Exception) {
toast(R.string.cant_open_last_read_chapter)
}
}
}
R.id.nav_more -> {
if (router.backstackSize == 1) {
router.pushController(SettingsMainController())

View File

@@ -91,4 +91,8 @@ class HistoryController : ComposeController<HistoryPresenter>(), RootController
activity.toast(R.string.no_next_chapter)
}
}
fun resumeLastChapterRead() {
presenter.resumeLastChapterRead()
}
}

View File

@@ -7,7 +7,7 @@ import androidx.paging.insertSeparators
import androidx.paging.map
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.model.HistoryWithRelations
@@ -36,7 +36,7 @@ import java.util.Date
*/
class HistoryPresenter(
private val getHistory: GetHistory = Injekt.get(),
private val getNextChapterForManga: GetNextChapterForManga = Injekt.get(),
private val getNextChapter: GetNextChapter = Injekt.get(),
private val deleteHistoryTable: DeleteHistoryTable = Injekt.get(),
private val removeHistoryById: RemoveHistoryById = Injekt.get(),
private val removeHistoryByMangaId: RemoveHistoryByMangaId = Injekt.get(),
@@ -101,7 +101,7 @@ class HistoryPresenter(
fun getNextChapterForManga(mangaId: Long, chapterId: Long) {
presenterScope.launchIO {
val chapter = getNextChapterForManga.await(mangaId, chapterId)
val chapter = getNextChapter.await(mangaId, chapterId)
launchUI {
view?.openChapter(chapter)
}
@@ -117,6 +117,15 @@ class HistoryPresenter(
}
}
}
fun resumeLastChapterRead() {
presenterScope.launchIO {
val chapter = getNextChapter.await()
launchUI {
view?.openChapter(chapter)
}
}
}
}
sealed class HistoryState {