mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 03:21:51 +01:00
Don't update last page read/read state of chapter if Incognito Mode is enabled
Actually closes #7228, which I forgot was about history more than trackers.
This commit is contained in:
parent
9766399539
commit
e323f3c25a
@ -435,12 +435,13 @@ class ReaderViewModel(
|
|||||||
currentPage = page.index + 1,
|
currentPage = page.index + 1,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
selectedChapter.chapter.last_page_read = page.index
|
if (!incognitoMode) {
|
||||||
val shouldTrack = !incognitoMode || hasTrackers
|
selectedChapter.chapter.last_page_read = page.index
|
||||||
if (selectedChapter.pages?.lastIndex == page.index && shouldTrack) {
|
if (selectedChapter.pages?.lastIndex == page.index) {
|
||||||
selectedChapter.chapter.read = true
|
selectedChapter.chapter.read = true
|
||||||
updateTrackChapterRead(selectedChapter)
|
updateTrackChapterRead(selectedChapter)
|
||||||
deleteChapterIfNeeded(selectedChapter)
|
deleteChapterIfNeeded(selectedChapter)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectedChapter != currentChapters.currChapter) {
|
if (selectedChapter != currentChapters.currChapter) {
|
||||||
@ -505,16 +506,17 @@ class ReaderViewModel(
|
|||||||
* @param currentChapter current chapter, which is going to be marked as read.
|
* @param currentChapter current chapter, which is going to be marked as read.
|
||||||
*/
|
*/
|
||||||
private fun deleteChapterIfNeeded(currentChapter: ReaderChapter) {
|
private fun deleteChapterIfNeeded(currentChapter: ReaderChapter) {
|
||||||
|
val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots().get()
|
||||||
|
if (removeAfterReadSlots == -1) return
|
||||||
|
|
||||||
// Determine which chapter should be deleted and enqueue
|
// Determine which chapter should be deleted and enqueue
|
||||||
val currentChapterPosition = chapterList.indexOf(currentChapter)
|
val currentChapterPosition = chapterList.indexOf(currentChapter)
|
||||||
val removeAfterReadSlots = downloadPreferences.removeAfterReadSlots().get()
|
|
||||||
val chapterToDelete = chapterList.getOrNull(currentChapterPosition - removeAfterReadSlots)
|
val chapterToDelete = chapterList.getOrNull(currentChapterPosition - removeAfterReadSlots)
|
||||||
|
|
||||||
// If chapter is completely read no need to download it
|
// If chapter is completely read, no need to download it
|
||||||
chapterToDownload = null
|
chapterToDownload = null
|
||||||
|
|
||||||
// Check if deleting option is enabled and chapter exists
|
if (chapterToDelete != null) {
|
||||||
if (removeAfterReadSlots != -1 && chapterToDelete != null) {
|
|
||||||
enqueueDeleteReadChapters(chapterToDelete)
|
enqueueDeleteReadChapters(chapterToDelete)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,22 +536,22 @@ class ReaderViewModel(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this [readerChapter] progress (last read page and whether it's read).
|
* Saves this [readerChapter] progress (last read page and whether it's read)
|
||||||
* If incognito mode isn't on or has at least 1 tracker
|
* if incognito mode isn't on.
|
||||||
*/
|
*/
|
||||||
private suspend fun saveChapterProgress(readerChapter: ReaderChapter) {
|
private suspend fun saveChapterProgress(readerChapter: ReaderChapter) {
|
||||||
if (!incognitoMode || hasTrackers) {
|
if (incognitoMode) return
|
||||||
val chapter = readerChapter.chapter
|
|
||||||
getCurrentChapter()?.requestedPage = chapter.last_page_read
|
val chapter = readerChapter.chapter
|
||||||
updateChapter.await(
|
getCurrentChapter()?.requestedPage = chapter.last_page_read
|
||||||
ChapterUpdate(
|
updateChapter.await(
|
||||||
id = chapter.id!!,
|
ChapterUpdate(
|
||||||
read = chapter.read,
|
id = chapter.id!!,
|
||||||
bookmark = chapter.bookmark,
|
read = chapter.read,
|
||||||
lastPageRead = chapter.last_page_read.toLong(),
|
bookmark = chapter.bookmark,
|
||||||
),
|
lastPageRead = chapter.last_page_read.toLong(),
|
||||||
)
|
),
|
||||||
}
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -713,7 +715,7 @@ class ReaderViewModel(
|
|||||||
val chapter = page.chapter.chapter
|
val chapter = page.chapter.chapter
|
||||||
val filenameSuffix = " - ${page.number}"
|
val filenameSuffix = " - ${page.number}"
|
||||||
return DiskUtil.buildValidFilename(
|
return DiskUtil.buildValidFilename(
|
||||||
"${manga.title} - ${chapter.name}".takeBytes(MAX_FILE_NAME_BYTES - filenameSuffix.byteSize()),
|
"${manga.title} - ${chapter.name}".takeBytes(DiskUtil.MAX_FILE_NAME_BYTES - filenameSuffix.byteSize()),
|
||||||
) + filenameSuffix
|
) + filenameSuffix
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -831,7 +833,7 @@ class ReaderViewModel(
|
|||||||
* will run in a background thread and errors are ignored.
|
* will run in a background thread and errors are ignored.
|
||||||
*/
|
*/
|
||||||
private fun updateTrackChapterRead(readerChapter: ReaderChapter) {
|
private fun updateTrackChapterRead(readerChapter: ReaderChapter) {
|
||||||
if (basePreferences.incognitoMode().get()) return
|
if (incognitoMode || !hasTrackers) return
|
||||||
if (!trackPreferences.autoUpdateTrack().get()) return
|
if (!trackPreferences.autoUpdateTrack().get()) return
|
||||||
|
|
||||||
val manga = manga ?: return
|
val manga = manga ?: return
|
||||||
@ -918,9 +920,4 @@ class ReaderViewModel(
|
|||||||
data class SavedImage(val result: SaveImageResult) : Event()
|
data class SavedImage(val result: SaveImageResult) : Event()
|
||||||
data class ShareImage(val uri: Uri, val page: ReaderPage) : Event()
|
data class ShareImage(val uri: Uri, val page: ReaderPage) : Event()
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
// Safe theoretical max filename size is 255 bytes and 1 char = 2-4 bytes (UTF-8)
|
|
||||||
private const val MAX_FILE_NAME_BYTES = 250
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -114,4 +114,7 @@ object DiskUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const val NOMEDIA_FILE = ".nomedia"
|
const val NOMEDIA_FILE = ".nomedia"
|
||||||
|
|
||||||
|
// Safe theoretical max filename size is 255 bytes and 1 char = 2-4 bytes (UTF-8)
|
||||||
|
const val MAX_FILE_NAME_BYTES = 250
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user