Fix Mangadex logout crashes

This commit is contained in:
Jobobby04 2021-12-18 21:45:34 -05:00
parent 6972edbcb4
commit a2df6a7f11

View File

@ -46,6 +46,7 @@ class MangaDexLoginHelper(val authServiceLazy: Lazy<MangaDexAuthService>, val pr
return withIOContext {
val loginRequest = LoginRequestDto(username, password)
val loginResult = runCatching { authService.login(loginRequest) }
.onFailure { this@MangaDexLoginHelper.xLogE("Error logging in", it) }
val e = loginResult.exceptionOrNull()
if (e is CancellationException) throw e
@ -77,7 +78,12 @@ class MangaDexLoginHelper(val authServiceLazy: Lazy<MangaDexAuthService>, val pr
suspend fun logout() {
return withIOContext {
withTimeoutOrNull(10.seconds) {
authService.logout()
runCatching {
authService.logout()
}.onFailure {
if (it is CancellationException) throw it
this@MangaDexLoginHelper.xLogE("Error logging out", it)
}
}
}
}