From c15e059e662fd6aab83bdf6c10123de833947406 Mon Sep 17 00:00:00 2001 From: gpanshu <91897496+gpanshu@users.noreply.github.com> Date: Fri, 2 Dec 2022 14:11:00 -0600 Subject: [PATCH] Fix for when move to idle state is called twice (#2152) --- .../statemachine/codegen/states/CredentialStoreState.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/states/CredentialStoreState.kt b/aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/states/CredentialStoreState.kt index 2e898502eb..aa8f01647f 100644 --- a/aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/states/CredentialStoreState.kt +++ b/aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/states/CredentialStoreState.kt @@ -64,7 +64,10 @@ internal sealed class CredentialStoreState : State { val action = credentialStoreActions.loadCredentialStoreAction(storeEvent.credentialType) StateResolution(LoadingStoredCredentials(), listOf(action)) } - is CredentialStoreEvent.EventType.ThrowError -> StateResolution(Error(storeEvent.error)) + is CredentialStoreEvent.EventType.ThrowError -> { + val action = credentialStoreActions.moveToIdleStateAction() + StateResolution(Error(storeEvent.error), listOf(action)) + } else -> defaultResolution } is LoadingStoredCredentials, is StoringCredentials, is ClearingCredentials -> when (storeEvent) { @@ -96,8 +99,7 @@ internal sealed class CredentialStoreState : State { } is Success, is Error -> when (storeEvent) { is CredentialStoreEvent.EventType.MoveToIdleState -> { - val action = credentialStoreActions.moveToIdleStateAction() - StateResolution(Idle(), listOf(action)) + StateResolution(Idle(), listOf()) } else -> StateResolution(oldState) }