Skip to content

Commit

Permalink
perf(auth): Fetch auth session (#3510)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dnys1 authored Aug 3, 2023
1 parent 98bdb14 commit c0fd1f8
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ final class CredentialStoreStateMachine
Future<void> resolve(CredentialStoreEvent event) async {
switch (event) {
case CredentialStoreLoadCredentialStore _:
emit(const CredentialStoreState.loadingStoredCredentials());
await onLoadCredentialStore(event);
if (currentState case final CredentialStoreSuccess success) {
emit(success);
} else {
emit(const CredentialStoreState.loadingStoredCredentials());
await onLoadCredentialStore(event);
}
case CredentialStoreStoreCredentials _:
emit(const CredentialStoreState.storingCredentials());
await onStoreCredentials(event);
Expand Down

0 comments on commit c0fd1f8

Please sign in to comment.