one more try to fix nosuchelement exception
This commit is contained in:
@@ -10,7 +10,6 @@ import dev.inmo.micro_utils.common.either
|
||||
import dev.inmo.micro_utils.repos.*
|
||||
import dev.inmo.postssystem.features.auth.client.createAuthorizedFeaturesDIModule
|
||||
import dev.inmo.postssystem.features.auth.client.ui.AuthUIError.AuthIncorrect
|
||||
import dev.inmo.postssystem.features.auth.client.ui.AuthUIError.ServerUnavailable
|
||||
import dev.inmo.postssystem.features.common.common.DBDropper
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
@@ -85,7 +84,7 @@ data class DefaultAuthSettings(
|
||||
currentModule ?.let { koin.loadModules(listOf(currentModule)) }
|
||||
}
|
||||
return when {
|
||||
!serverAvailable -> ServerUnavailable
|
||||
!serverAvailable -> AuthUIError.ServerUnavailable
|
||||
!authCorrect -> AuthIncorrect
|
||||
else -> {
|
||||
_authorizedDIModule.value = newModule
|
||||
|
@@ -1,12 +1,8 @@
|
||||
package dev.inmo.postssystem.features.auth.client.ui
|
||||
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMState
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMStateSerializer
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class AuthUIFSMState(
|
||||
@Serializable(UIFSMStateSerializer::class)
|
||||
override val from: UIFSMState?,
|
||||
override val context: String = "main"
|
||||
) : UIFSMState
|
||||
|
@@ -3,21 +3,21 @@ package dev.inmo.postssystem.features.auth.client.ui
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
sealed class AuthUIError {
|
||||
sealed interface AuthUIError {
|
||||
@Serializable
|
||||
object ServerUnavailable : AuthUIError()
|
||||
object ServerUnavailable : AuthUIError
|
||||
@Serializable
|
||||
object AuthIncorrect : AuthUIError()
|
||||
object AuthIncorrect : AuthUIError
|
||||
}
|
||||
|
||||
@Serializable
|
||||
sealed class AuthUIState {
|
||||
sealed interface AuthUIState {
|
||||
@Serializable
|
||||
data class Init(val showError: AuthUIError? = null) : AuthUIState()
|
||||
data class Init(val showError: AuthUIError? = null) : AuthUIState
|
||||
@Serializable
|
||||
object Loading : AuthUIState()
|
||||
object Loading : AuthUIState
|
||||
@Serializable
|
||||
object Authorized : AuthUIState()
|
||||
object Authorized : AuthUIState
|
||||
|
||||
companion object {
|
||||
val DefaultInit = Init()
|
||||
|
@@ -10,7 +10,6 @@ import dev.inmo.micro_utils.coroutines.launchSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.coroutines.subscribeSafelyWithoutExceptions
|
||||
import dev.inmo.micro_utils.fsm.common.StatesMachine
|
||||
import dev.inmo.postssystem.features.auth.client.ui.AuthUIError.AuthIncorrect
|
||||
import dev.inmo.postssystem.features.auth.client.ui.AuthUIError.ServerUnavailable
|
||||
import dev.inmo.postssystem.features.common.common.*
|
||||
import dev.inmo.postssystem.features.common.common.ui.JSView
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.*
|
||||
@@ -98,7 +97,7 @@ class AuthView(
|
||||
disabled.value = false
|
||||
|
||||
errorText.value = when (it.showError) {
|
||||
ServerUnavailable -> "Server unavailable"
|
||||
AuthUIError.ServerUnavailable -> "Server unavailable"
|
||||
AuthIncorrect -> {
|
||||
passwordState.value = ""
|
||||
"Username or password is incorrect"
|
||||
|
@@ -8,7 +8,6 @@ import kotlinx.serialization.encoding.Decoder
|
||||
import kotlinx.serialization.encoding.Encoder
|
||||
import kotlin.jvm.JvmInline
|
||||
|
||||
@Serializable(AuthKeySerializer::class)
|
||||
sealed interface AuthKey
|
||||
|
||||
@Serializable
|
||||
@@ -18,34 +17,6 @@ private data class AuthKeySurrogate(
|
||||
val refreshToken: RefreshToken?
|
||||
)
|
||||
|
||||
@Serializer(AuthKey::class)
|
||||
object AuthKeySerializer : KSerializer<AuthKey> {
|
||||
override val descriptor: SerialDescriptor
|
||||
get() = AuthKeySurrogate.serializer().descriptor
|
||||
|
||||
override fun deserialize(decoder: Decoder): AuthKey {
|
||||
val surrogate = AuthKeySurrogate.serializer().deserialize(decoder)
|
||||
when {
|
||||
surrogate.authCreds != null -> return surrogate.authCreds
|
||||
surrogate.token != null -> return surrogate.token
|
||||
surrogate.refreshToken != null -> return surrogate.refreshToken
|
||||
}
|
||||
error("Unsupported version of auth key surrogate")
|
||||
}
|
||||
|
||||
override fun serialize(encoder: Encoder, value: AuthKey) {
|
||||
AuthKeySurrogate.serializer().serialize(
|
||||
encoder,
|
||||
AuthKeySurrogate(
|
||||
value as? AuthCreds,
|
||||
value as? AuthToken,
|
||||
value as? RefreshToken
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Serializable
|
||||
@SerialName("authcreds")
|
||||
data class AuthCreds(
|
||||
|
Reference in New Issue
Block a user