Prechádzať zdrojové kódy

Show MAL relogin message on update, localize error message

arkon 4 rokov pred
rodič
commit
2cb3984d68

+ 5 - 1
app/src/main/java/eu/kanade/tachiyomi/Migrations.kt

@@ -10,6 +10,7 @@ import eu.kanade.tachiyomi.data.track.TrackManager
 import eu.kanade.tachiyomi.data.updater.UpdaterJob
 import eu.kanade.tachiyomi.extension.ExtensionUpdateJob
 import eu.kanade.tachiyomi.ui.library.LibrarySort
+import eu.kanade.tachiyomi.util.system.toast
 import eu.kanade.tachiyomi.widget.ExtendedNavigationView
 import uy.kohesive.injekt.Injekt
 import uy.kohesive.injekt.api.get
@@ -118,7 +119,10 @@ object Migrations {
 
                 // Force MAL log out due to login flow change
                 val trackManager = Injekt.get<TrackManager>()
-                trackManager.myAnimeList.logout()
+                if (trackManager.myAnimeList.isLogged) {
+                    trackManager.myAnimeList.logout()
+                    context.toast(R.string.myanimelist_relogin)
+                }
             }
             return true
         }

+ 1 - 1
app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt

@@ -111,7 +111,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) {
 
     fun ensureLoggedIn() {
         if (isAuthorized) return
-        if (!isLogged) throw Exception("MAL login credentials not found")
+        if (!isLogged) throw Exception(context.getString(R.string.myanimelist_creds_missing))
     }
 
     override fun logout() {

+ 2 - 0
app/src/main/res/values/strings.xml

@@ -569,6 +569,8 @@
     <string name="track_type">Type</string>
     <string name="track_author">Author</string>
     <string name="error_invalid_date_supplied">Invalid date supplied</string>
+    <string name="myanimelist_creds_missing">MAL login credentials not found</string>
+    <string name="myanimelist_relogin">Please login to MAL again</string>
 
     <!-- Category activity -->
     <string name="error_category_exists">A category with this name already exists!</string>