Skip to content

Commit c0fd1f8

Browse files
authored
perf(auth): Fetch auth session (#3510)
fix(auth): Fetch auth session performance When a query is made to the credential store, we currently always hit the underlying store. However, due to the queuing nature of the store, if it's in a `success` state we can immediately return since we are guaranteed to have the latest data.
1 parent 98bdb14 commit c0fd1f8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/auth/amplify_auth_cognito_dart/lib/src/state/machines/credential_store_state_machine.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,12 @@ final class CredentialStoreStateMachine
4949
Future<void> resolve(CredentialStoreEvent event) async {
5050
switch (event) {
5151
case CredentialStoreLoadCredentialStore _:
52-
emit(const CredentialStoreState.loadingStoredCredentials());
53-
await onLoadCredentialStore(event);
52+
if (currentState case final CredentialStoreSuccess success) {
53+
emit(success);
54+
} else {
55+
emit(const CredentialStoreState.loadingStoredCredentials());
56+
await onLoadCredentialStore(event);
57+
}
5458
case CredentialStoreStoreCredentials _:
5559
emit(const CredentialStoreState.storingCredentials());
5660
await onStoreCredentials(event);

0 commit comments

Comments
 (0)