Localize "No chapters found" error

This commit is contained in:
arkon 2020-09-04 15:21:09 -04:00
parent 7a33e198dc
commit 66baf01e43
6 changed files with 30 additions and 9 deletions

View File

@ -32,6 +32,7 @@ import eu.kanade.tachiyomi.data.database.models.TrackImpl
import eu.kanade.tachiyomi.data.notification.Notifications
import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.util.chapter.NoChaptersException
import eu.kanade.tachiyomi.util.system.acquireWakeLock
import eu.kanade.tachiyomi.util.system.isServiceRunning
import java.io.File
@ -398,7 +399,12 @@ class BackupRestoreService : Service() {
return backupManager.restoreChapterFetchObservable(source, manga, chapters)
// If there's any error, return empty update and continue.
.onErrorReturn {
errors.add(Date() to "${manga.title} - ${it.message}")
val errorMessage = if (it is NoChaptersException) {
getString(R.string.no_chapters_error)
} else {
it.message
}
errors.add(Date() to "${manga.title} - $errorMessage")
Pair(emptyList(), emptyList())
}
}

View File

@ -6,6 +6,7 @@ import android.content.Intent
import android.os.Build
import android.os.IBinder
import android.os.PowerManager
import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.cache.CoverCache
import eu.kanade.tachiyomi.data.database.DatabaseHelper
import eu.kanade.tachiyomi.data.database.models.Category
@ -21,6 +22,7 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.track.TrackManager
import eu.kanade.tachiyomi.source.SourceManager
import eu.kanade.tachiyomi.source.model.SManga
import eu.kanade.tachiyomi.util.chapter.NoChaptersException
import eu.kanade.tachiyomi.util.chapter.syncChaptersWithSource
import eu.kanade.tachiyomi.util.prepUpdateCover
import eu.kanade.tachiyomi.util.shouldDownloadNewChapters
@ -268,7 +270,12 @@ class LibraryUpdateService(
updateManga(manga)
// If there's any error, return empty update and continue.
.onErrorReturn {
failedUpdates.add(Pair(manga, it.message))
val errorMessage = if (it is NoChaptersException) {
getString(R.string.no_chapters_error)
} else {
it.message
}
failedUpdates.add(Pair(manga, errorMessage))
Pair(emptyList(), emptyList())
}
// Filter out mangas without new chapters (or failed).

View File

@ -65,6 +65,7 @@ import eu.kanade.tachiyomi.ui.reader.ReaderActivity
import eu.kanade.tachiyomi.ui.recent.history.HistoryController
import eu.kanade.tachiyomi.ui.recent.updates.UpdatesController
import eu.kanade.tachiyomi.ui.webview.WebViewActivity
import eu.kanade.tachiyomi.util.chapter.NoChaptersException
import eu.kanade.tachiyomi.util.hasCustomCover
import eu.kanade.tachiyomi.util.system.getResourceColor
import eu.kanade.tachiyomi.util.system.toast
@ -696,8 +697,12 @@ class MangaController :
fun onFetchChaptersError(error: Throwable) {
isRefreshingChapters = false
updateRefreshing()
if (error is NoChaptersException) {
activity?.toast(activity?.getString(R.string.no_chapters_error))
} else {
activity?.toast(error.message)
}
}
fun onChapterStatusChange(download: Download) {
chaptersAdapter?.currentItems?.find { it.id == download.chapter.id }?.let {

View File

@ -28,7 +28,7 @@ fun syncChaptersWithSource(
source: Source
): Pair<List<Chapter>, List<Chapter>> {
if (rawSourceChapters.isEmpty()) {
throw Exception("No chapters found")
throw NoChaptersException()
}
val downloadManager: DownloadManager = Injekt.get()

View File

@ -0,0 +1,3 @@
package eu.kanade.tachiyomi.util.chapter
class NoChaptersException : Exception()

View File

@ -524,6 +524,7 @@
<string name="download_unread">Unread</string>
<string name="confirm_delete_chapters">Are you sure you want to delete the selected chapters?</string>
<string name="invalid_download_dir">Invalid download location</string>
<string name="no_chapters_error">No chapters found</string>
<!-- Tracking Screen -->
<string name="manga_tracking_tab">Tracking</string>
@ -590,6 +591,10 @@
<string name="transition_pages_error">Failed to load pages: %1$s</string>
<string name="page_list_empty_error">No pages found</string>
<string name="loader_not_implemented_error">Source not found</string>
<plurals name="missing_chapters_warning">
<item quantity="one">There is 1 missing chapter</item>
<item quantity="other">There are %d missing chapters</item>
</plurals>
<!-- Updates fragment -->
<string name="updating_library">Updating library</string>
@ -700,9 +705,4 @@
<string name="tapping_inverted_horizontal">Horizontal</string>
<string name="tapping_inverted_vertical">Vertical</string>
<string name="tapping_inverted_both">Both</string>
<plurals name="missing_chapters_warning">
<item quantity="one">There is 1 missing chapter</item>
<item quantity="other">There are %d missing chapters</item>
</plurals>
</resources>