Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to update trackers when chapter marked as read #1177

Merged
merged 10 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions app/src/main/java/eu/kanade/tachiyomi/ui/manga/MangaScreenModel.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package eu.kanade.tachiyomi.ui.manga

import android.content.Context
import androidx.compose.material3.SnackbarDuration
import androidx.compose.material3.SnackbarHostState
import androidx.compose.material3.SnackbarResult
import androidx.compose.runtime.Immutable
Expand All @@ -21,6 +22,7 @@ import eu.kanade.domain.manga.model.chaptersFiltered
import eu.kanade.domain.manga.model.downloadedFilter
import eu.kanade.domain.manga.model.toSManga
import eu.kanade.domain.track.interactor.AddTracks
import eu.kanade.domain.track.interactor.TrackChapter
import eu.kanade.presentation.manga.DownloadAction
import eu.kanade.presentation.manga.components.ChapterDownloadAction
import eu.kanade.presentation.util.formattedMessage
Expand Down Expand Up @@ -89,6 +91,7 @@ class MangaScreenModel(
private val libraryPreferences: LibraryPreferences = Injekt.get(),
readerPreferences: ReaderPreferences = Injekt.get(),
private val trackerManager: TrackerManager = Injekt.get(),
private val trackChapter: TrackChapter = Injekt.get(),
private val downloadManager: DownloadManager = Injekt.get(),
private val downloadCache: DownloadCache = Injekt.get(),
private val getMangaAndChapters: GetMangaWithChapters = Injekt.get(),
Expand Down Expand Up @@ -718,6 +721,26 @@ class MangaScreenModel(
read = read,
chapters = chapters.toTypedArray(),
)

Animeboynz marked this conversation as resolved.
Show resolved Hide resolved
if (!read) return@launchIO
Animeboynz marked this conversation as resolved.
Show resolved Hide resolved
val tracks = getTracks.await(mangaId)
val maxChapterNumber = chapters.maxOf { it.chapterNumber }
val shouldPromptTrackingUpdate = tracks.any { track ->
maxChapterNumber > track.lastChapterRead
}

if (!shouldPromptTrackingUpdate) return@launchIO
Animeboynz marked this conversation as resolved.
Show resolved Hide resolved
val formattedChapterNumber = maxChapterNumber.toInt()
val result = snackbarHostState.showSnackbar(
message = context.stringResource(MR.strings.confirm_tracker_update, formattedChapterNumber),
Animeboynz marked this conversation as resolved.
Show resolved Hide resolved
actionLabel = context.stringResource(MR.strings.action_ok),
duration = SnackbarDuration.Short,
withDismissAction = true,
)

if (result == SnackbarResult.ActionPerformed) {
trackChapter.await(context, mangaId, maxChapterNumber)
}
}
toggleAllSelection(false)
Animeboynz marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
1 change: 1 addition & 0 deletions i18n/src/commonMain/moko-resources/base/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@
<string name="are_you_sure">Are you sure?</string>
<string name="exclude_scanlators">Exclude scanlators</string>
<string name="no_scanlators_found">No scanlators found</string>
<string name="confirm_tracker_update">Update trackers to chapter %d?</string>

<!-- Tracking Screen -->
<string name="manga_tracking_tab">Tracking</string>
Expand Down