mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-13 20:48: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:
@@ -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())
|
||||
|
||||
@@ -91,4 +91,8 @@ class HistoryController : ComposeController<HistoryPresenter>(), RootController
|
||||
activity.toast(R.string.no_next_chapter)
|
||||
}
|
||||
}
|
||||
|
||||
fun resumeLastChapterRead() {
|
||||
presenter.resumeLastChapterRead()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user