New attempt to logout

This commit is contained in:
Jobobby04 2021-08-01 21:56:04 -04:00
parent 46d33b0cfb
commit 9916d89296

View File

@ -9,7 +9,8 @@ import exh.md.dto.LoginRequestDto
import exh.md.dto.RefreshTokenDto
import exh.md.service.MangaDexAuthService
import exh.md.utils.MdUtil
import kotlinx.coroutines.CancellationException
import exh.util.seconds
import kotlinx.coroutines.*
import kotlinx.serialization.encodeToString
class MangaDexLoginHelper(val authServiceLazy: Lazy<MangaDexAuthService>, val preferences: PreferencesHelper, val mdList: MdList) {
@ -72,11 +73,14 @@ class MangaDexLoginHelper(val authServiceLazy: Lazy<MangaDexAuthService>, val pr
suspend fun logout() {
return withIOContext {
try {
if (isAuthenticated()) {
authService.logout()
} else {
if (refreshToken()) {
coroutineScope {
launch {
authService.logout()
cancel()
}
launch {
delay(30.seconds)
cancel()
}
}
} catch (e: Exception) {