diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt index 43066e7830..7fc39d2fd5 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeList.kt @@ -104,7 +104,7 @@ class MyAnimeList(private val context: Context, id: Int) : TrackService(id) { } } - private suspend fun refreshLogin() { + suspend fun refreshLogin() { val username = getUsername() val password = getPassword() logout() diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt index bc017f8479..2a6c2720a3 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/track/myanimelist/MyAnimeListInterceptor.kt @@ -21,7 +21,17 @@ class MyAnimeListInterceptor(private val myanimelist: MyAnimeList) : Interceptor myanimelist.ensureLoggedIn() } val request = chain.request() - return chain.proceed(updateRequest(request)) + var response = chain.proceed(updateRequest(request)) + + if (response.code == 400) { + scope.launch { + myanimelist.refreshLogin() + } + response.close() + response = chain.proceed(updateRequest(request)) + } + + return response } private fun updateRequest(request: Request): Request {