@zeniai/client-epic-state 5.0.34 → 5.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  import { from, of } from 'rxjs';
2
- import { catchError, concatMap, filter, mergeMap, switchMap, } from 'rxjs/operators';
2
+ import { catchError, concatMap, exhaustMap, filter, mergeMap, } from 'rxjs/operators';
3
3
  import { openSnackbar } from '../../../entity/snackbar/snackbarReducer';
4
4
  import { createZeniAPIStatus } from '../../../responsePayload';
5
5
  import { approveOAuthConsent, approveOAuthConsentFailure, approveOAuthConsentSuccess, } from '../zeniOAuthReducer';
@@ -9,10 +9,11 @@ const failureSnackbar = (reason) => openSnackbar({
9
9
  type: 'error',
10
10
  variables: [{ variableName: '__reason__', variableValue: reason }],
11
11
  });
12
- export const approveOAuthConsentEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(approveOAuthConsent.match), switchMap((action) => {
13
- if (state$.value.zeniOAuthViewState.fetchState === 'In-Progress') {
14
- return from([]);
15
- }
12
+ export const approveOAuthConsentEpic = (actions$, _state$, zeniAPI) => actions$.pipe(filter(approveOAuthConsent.match),
13
+ // `approveOAuthConsent` reducer sets fetchState to In-Progress before epics
14
+ // run, so a guard on In-Progress would block every legitimate request.
15
+ // exhaustMap drops duplicate approve clicks while the HTTP call is in flight.
16
+ exhaustMap((action) => {
16
17
  const { userId, zeniSessionId, tenantId, clientId, redirectUri, codeChallenge, codeChallengeMethod, state, responseType, } = action.payload;
17
18
  const authHeaders = {
18
19
  'zeni-user-id': userId,