mirror of
https://github.com/mihonapp/mihon.git
synced 2026-10-19 15:12:36 -07:00
Fix reading history being double counted
Restore groups a backup's history entries by chapter before comparing them with the stored row, so a backup carrying one entry per copy of a duplicated chapter no longer adds its reading time more than once or moves the last read backwards. A removed history entry keeps its 0 instead of becoming NULL, a tracker's start date skips removed history, and the reader clears a session's start time before saving it, so overlapping saves can't count it twice.
This commit is contained in:
@@ -57,9 +57,8 @@ class AddTracks(
|
||||
|
||||
if (track.startDate <= 0) {
|
||||
val firstReadChapterDate = getHistory.await(mangaId)
|
||||
.sortedBy { it.readAt }
|
||||
.firstOrNull()
|
||||
?.readAt
|
||||
.mapNotNull { it.readAt?.takeIf { readAt -> readAt.time > 0 } }
|
||||
.minOrNull()
|
||||
|
||||
firstReadChapterDate?.let {
|
||||
val startDate = firstReadChapterDate.time.convertEpochMillisZone(
|
||||
|
||||
@@ -629,9 +629,9 @@ class ReaderViewModel(
|
||||
val chapterId = readerChapter.chapter.id!!
|
||||
val endTime = Date()
|
||||
val sessionReadDuration = chapterReadStartTime?.let { endTime.time - it } ?: 0
|
||||
chapterReadStartTime = null
|
||||
|
||||
upsertHistory.await(HistoryUpdate(chapterId, endTime, sessionReadDuration))
|
||||
chapterReadStartTime = null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user