New attempt to logout
This commit is contained in:
parent
46d33b0cfb
commit
9916d89296
@ -9,7 +9,8 @@ import exh.md.dto.LoginRequestDto
|
|||||||
import exh.md.dto.RefreshTokenDto
|
import exh.md.dto.RefreshTokenDto
|
||||||
import exh.md.service.MangaDexAuthService
|
import exh.md.service.MangaDexAuthService
|
||||||
import exh.md.utils.MdUtil
|
import exh.md.utils.MdUtil
|
||||||
import kotlinx.coroutines.CancellationException
|
import exh.util.seconds
|
||||||
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.serialization.encodeToString
|
import kotlinx.serialization.encodeToString
|
||||||
|
|
||||||
class MangaDexLoginHelper(val authServiceLazy: Lazy<MangaDexAuthService>, val preferences: PreferencesHelper, val mdList: MdList) {
|
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() {
|
suspend fun logout() {
|
||||||
return withIOContext {
|
return withIOContext {
|
||||||
try {
|
try {
|
||||||
if (isAuthenticated()) {
|
coroutineScope {
|
||||||
authService.logout()
|
launch {
|
||||||
} else {
|
|
||||||
if (refreshToken()) {
|
|
||||||
authService.logout()
|
authService.logout()
|
||||||
|
cancel()
|
||||||
|
}
|
||||||
|
launch {
|
||||||
|
delay(30.seconds)
|
||||||
|
cancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user