mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Enhance incognito mode (#4073)
* When in Incognito Mode don't set lastUsedSource * When in Incognito Mode don't save chapter progress Still allows tracking and mark as read when reaching last page * When in Incognito Mode don't mark as read (overwritten if hasTrackers)
This commit is contained in:
parent
ff66f307dd
commit
c9c0f3d014
2 changed files with 22 additions and 7 deletions
|
@ -194,7 +194,9 @@ class SourceController :
|
|||
* Opens a catalogue with the given controller.
|
||||
*/
|
||||
private fun openSource(source: CatalogueSource, controller: BrowseSourceController) {
|
||||
preferences.lastUsedSource().set(source.id)
|
||||
if (!preferences.incognitoMode().get()) {
|
||||
preferences.lastUsedSource().set(source.id)
|
||||
}
|
||||
parentController!!.router.pushController(controller.withFadeTransaction())
|
||||
}
|
||||
|
||||
|
|
|
@ -133,6 +133,13 @@ class ReaderPresenter(
|
|||
}.map(::ReaderChapter)
|
||||
}
|
||||
|
||||
private var hasTrackers: Boolean = false
|
||||
private val checkTrackers: (Manga) -> Unit = { manga ->
|
||||
val tracks = db.getTracks(manga).executeAsBlocking()
|
||||
|
||||
hasTrackers = tracks.size > 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the presenter is created. It retrieves the saved active chapter if the process
|
||||
* was restored.
|
||||
|
@ -224,6 +231,8 @@ class ReaderPresenter(
|
|||
this.manga = manga
|
||||
if (chapterId == -1L) chapterId = initialChapterId
|
||||
|
||||
checkTrackers(manga)
|
||||
|
||||
val context = Injekt.get<Application>()
|
||||
val source = sourceManager.getOrStub(manga.source)
|
||||
loader = ChapterLoader(context, downloadManager, manga, source)
|
||||
|
@ -357,7 +366,8 @@ class ReaderPresenter(
|
|||
|
||||
// Save last page read and mark as read if needed
|
||||
selectedChapter.chapter.last_page_read = page.index
|
||||
if (selectedChapter.pages?.lastIndex == page.index) {
|
||||
val shouldTrack = !preferences.incognitoMode().get() || hasTrackers
|
||||
if (selectedChapter.pages?.lastIndex == page.index && shouldTrack) {
|
||||
selectedChapter.chapter.read = true
|
||||
updateTrackChapterRead(selectedChapter)
|
||||
deleteChapterIfNeeded(selectedChapter)
|
||||
|
@ -408,16 +418,19 @@ class ReaderPresenter(
|
|||
|
||||
/**
|
||||
* Saves this [chapter] progress (last read page and whether it's read).
|
||||
* If incognito mode isn't on or has at least 1 tracker
|
||||
*/
|
||||
private fun saveChapterProgress(chapter: ReaderChapter) {
|
||||
db.updateChapterProgress(chapter.chapter).asRxCompletable()
|
||||
.onErrorComplete()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
if (!preferences.incognitoMode().get() || hasTrackers) {
|
||||
db.updateChapterProgress(chapter.chapter).asRxCompletable()
|
||||
.onErrorComplete()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves this [chapter] last read history.
|
||||
* Saves this [chapter] last read history if incognito mode isn't on.
|
||||
*/
|
||||
private fun saveChapterHistory(chapter: ReaderChapter) {
|
||||
if (!preferences.incognitoMode().get()) {
|
||||
|
|
Loading…
Reference in a new issue