From 8a6a104987738c7251097f172d24aa7235a86e96 Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 11 Aug 2023 09:30:35 -0400 Subject: [PATCH] Set tracker finished date when manually updating to last chapter Closes #9834 Individual tracker implementations already handle setting it too on update. --- .../eu/kanade/tachiyomi/data/track/TrackService.kt | 10 +++++----- .../tachiyomi/data/chapter/ChapterRepositoryImpl.kt | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt index a24afd2ff1..d7dd11c945 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/TrackService.kt @@ -5,7 +5,6 @@ import androidx.annotation.CallSuper import androidx.annotation.ColorInt import androidx.annotation.DrawableRes import androidx.annotation.StringRes -import eu.kanade.domain.base.BasePreferences import eu.kanade.domain.chapter.interactor.SyncChaptersWithTrackServiceTwoWay import eu.kanade.domain.track.model.toDbTrack import eu.kanade.domain.track.model.toDomainTrack @@ -31,9 +30,9 @@ import tachiyomi.domain.track.model.Track as DomainTrack abstract class TrackService(val id: Long) { - val preferences: BasePreferences by injectLazy() val trackPreferences: TrackPreferences by injectLazy() val networkService: NetworkHelper by injectLazy() + private val insertTrack: InsertTrack by injectLazy() open val client: OkHttpClient get() = networkService.client @@ -112,7 +111,7 @@ abstract class TrackService(val id: Long) { var track = item.toDomainTrack(idRequired = false) ?: return@withIOContext - Injekt.get().await(track) + insertTrack.await(track) // Update chapter progress if newer chapters marked read locally if (hasReadChapters) { @@ -120,7 +119,7 @@ abstract class TrackService(val id: Long) { .sortedBy { it.chapterNumber } .takeWhile { it.read } .lastOrNull() - ?.chapterNumber?.toDouble() ?: -1.0 + ?.chapterNumber ?: -1.0 if (latestLocalReadChapterNumber > track.lastChapterRead) { track = track.copy( @@ -169,6 +168,7 @@ abstract class TrackService(val id: Long) { track.last_chapter_read = chapterNumber.toFloat() if (track.total_chapters != 0 && track.last_chapter_read.toInt() == track.total_chapters) { track.status = getCompletionStatus() + track.finished_reading_date = System.currentTimeMillis() } withIOContext { updateRemote(track) } } @@ -193,7 +193,7 @@ abstract class TrackService(val id: Long) { try { update(track) track.toDomainTrack(idRequired = false)?.let { - Injekt.get().await(it) + insertTrack.await(it) } } catch (e: Exception) { logcat(LogPriority.ERROR, e) { "Failed to update remote track data id=$id" } diff --git a/data/src/main/java/tachiyomi/data/chapter/ChapterRepositoryImpl.kt b/data/src/main/java/tachiyomi/data/chapter/ChapterRepositoryImpl.kt index a5c462d777..45a61e3633 100644 --- a/data/src/main/java/tachiyomi/data/chapter/ChapterRepositoryImpl.kt +++ b/data/src/main/java/tachiyomi/data/chapter/ChapterRepositoryImpl.kt @@ -58,7 +58,7 @@ class ChapterRepositoryImpl( read = chapterUpdate.read, bookmark = chapterUpdate.bookmark, lastPageRead = chapterUpdate.lastPageRead, - chapterNumber = chapterUpdate.chapterNumber?.toDouble(), + chapterNumber = chapterUpdate.chapterNumber, sourceOrder = chapterUpdate.sourceOrder, dateFetch = chapterUpdate.dateFetch, dateUpload = chapterUpdate.dateUpload,