diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt index 5ad52d488..2ec3cddd9 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/mutations/ChapterMutation.kt @@ -10,6 +10,7 @@ import suwayomi.tachidesk.graphql.types.ChapterMetaType import suwayomi.tachidesk.graphql.types.ChapterType import suwayomi.tachidesk.manga.impl.Chapter import suwayomi.tachidesk.manga.impl.chapter.getChapterDownloadReadyById +import suwayomi.tachidesk.manga.impl.track.Track import suwayomi.tachidesk.manga.model.table.ChapterMetaTable import suwayomi.tachidesk.manga.model.table.ChapterTable import suwayomi.tachidesk.server.JavalinSetup.future @@ -69,6 +70,13 @@ class ChapterMutation { update[lastReadAt] = now } } + if (patch.isRead == true) { + val mangaIds = + ChapterTable.slice(ChapterTable.manga).select { ChapterTable.id inList ids } + .map { it[ChapterTable.manga].value } + .toSet() + Track.asyncTrackChapter(mangaIds) + } } } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt index d22c5ae4f..daf3cfb4c 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/Chapter.kt @@ -439,7 +439,7 @@ object Chapter { } if (isRead == true || markPrevRead == true) { - Track.asyncTrackChapter(mangaId) + Track.asyncTrackChapter(setOf(mangaId)) } } @@ -527,9 +527,9 @@ object Chapter { transaction { ChapterTable.select { condition } .map { it[ChapterTable.manga].value } - .distinct() + .toSet() } - mangaIds.forEach { Track.asyncTrackChapter(it) } + Track.asyncTrackChapter(mangaIds) } } diff --git a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt index 222fe3acb..98c8c37bc 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/manga/impl/track/Track.kt @@ -235,9 +235,14 @@ object Track { upsertTrackRecord(track) } - fun asyncTrackChapter(mangaId: Int) { + fun asyncTrackChapter(mangaIds: Set) { + if (!TrackerManager.hasLoggedTracker()) { + return + } scope.launch { - trackChapter(mangaId) + mangaIds.forEach { + trackChapter(it) + } } } @@ -266,10 +271,6 @@ object Track { mangaId: Int, chapterNumber: Double, ) { - if (!TrackerManager.hasLoggedTracker()) { - return - } - val records = transaction { TrackRecordTable.select { TrackRecordTable.mangaId eq mangaId }