@zeniai/client-epic-state 5.1.18-betaRD3 → 5.1.18-betaRD4

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.
@@ -39,18 +39,20 @@ groupBy((action) => action.payload.selectedTab), mergeMap((group$) => group$.pip
39
39
  return zeniAPI
40
40
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
41
41
  .pipe(mergeMap((response) => {
42
+ // Stale-response guard: if search was cleared while this
43
+ // request was in-flight (restoreFullDatasetSnapshot ran),
44
+ // discard results and errors to avoid overwriting the restored
45
+ // IDs/counts or marking the tab as Error. Covers both the
46
+ // success and failure branches. switchMap only cancels on a new
47
+ // fetchTransactionCategorization for the same tab; restore
48
+ // doesn't dispatch one, so we guard here instead.
49
+ const currentSearchString = state$.value.expenseAutomationTransactionsViewState
50
+ .transactionCategorizationView[selectedTab].uiState
51
+ .searchString;
52
+ if (currentSearchString !== requestSearchString) {
53
+ return EMPTY;
54
+ }
42
55
  if (isSuccessResponse(response) && response.data != null) {
43
- // Stale-response guard: if search was cleared while this
44
- // request was in-flight (restoreFullDatasetSnapshot ran),
45
- // discard results to avoid overwriting the restored IDs and
46
- // counts. switchMap only cancels on a new fetchTransactionCategorization
47
- // for the same tab; restore doesn't dispatch one, so we guard here.
48
- const currentSearchString = state$.value.expenseAutomationTransactionsViewState
49
- .transactionCategorizationView[selectedTab].uiState
50
- .searchString;
51
- if (currentSearchString !== requestSearchString) {
52
- return EMPTY;
53
- }
54
56
  const updateActions = [];
55
57
  updateActions.push(updateTransactions(response.data.transactions, (value) => value.transaction_id, 'merge'));
56
58
  const transactionIds = response.data.transactions.map((transaction) => transaction.transaction_id);
@@ -101,10 +103,18 @@ groupBy((action) => action.payload.selectedTab), mergeMap((group$) => group$.pip
101
103
  status: response.status,
102
104
  }));
103
105
  }
104
- }), catchError((error) => of(fetchTransactionCategorizationFailure({
105
- selectedPeriod,
106
- selectedTab,
107
- status: createZeniAPIStatus('Unexpected Error', 'fetch Transaction Categorization REST API call errored out' +
108
- JSON.stringify(error)),
109
- }))));
106
+ }), catchError((error) => {
107
+ const currentSearchString = state$.value.expenseAutomationTransactionsViewState
108
+ .transactionCategorizationView[selectedTab].uiState
109
+ .searchString;
110
+ if (currentSearchString !== requestSearchString) {
111
+ return EMPTY;
112
+ }
113
+ return of(fetchTransactionCategorizationFailure({
114
+ selectedPeriod,
115
+ selectedTab,
116
+ status: createZeniAPIStatus('Unexpected Error', 'fetch Transaction Categorization REST API call errored out' +
117
+ JSON.stringify(error)),
118
+ }));
119
+ }));
110
120
  }))));
@@ -42,18 +42,20 @@ const fetchTransactionCategorizationEpic = (actions$, state$, zeniAPI) => action
42
42
  return zeniAPI
43
43
  .getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
44
44
  .pipe((0, operators_1.mergeMap)((response) => {
45
+ // Stale-response guard: if search was cleared while this
46
+ // request was in-flight (restoreFullDatasetSnapshot ran),
47
+ // discard results and errors to avoid overwriting the restored
48
+ // IDs/counts or marking the tab as Error. Covers both the
49
+ // success and failure branches. switchMap only cancels on a new
50
+ // fetchTransactionCategorization for the same tab; restore
51
+ // doesn't dispatch one, so we guard here instead.
52
+ const currentSearchString = state$.value.expenseAutomationTransactionsViewState
53
+ .transactionCategorizationView[selectedTab].uiState
54
+ .searchString;
55
+ if (currentSearchString !== requestSearchString) {
56
+ return rxjs_1.EMPTY;
57
+ }
45
58
  if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
46
- // Stale-response guard: if search was cleared while this
47
- // request was in-flight (restoreFullDatasetSnapshot ran),
48
- // discard results to avoid overwriting the restored IDs and
49
- // counts. switchMap only cancels on a new fetchTransactionCategorization
50
- // for the same tab; restore doesn't dispatch one, so we guard here.
51
- const currentSearchString = state$.value.expenseAutomationTransactionsViewState
52
- .transactionCategorizationView[selectedTab].uiState
53
- .searchString;
54
- if (currentSearchString !== requestSearchString) {
55
- return rxjs_1.EMPTY;
56
- }
57
59
  const updateActions = [];
58
60
  updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id, 'merge'));
59
61
  const transactionIds = response.data.transactions.map((transaction) => transaction.transaction_id);
@@ -104,11 +106,19 @@ const fetchTransactionCategorizationEpic = (actions$, state$, zeniAPI) => action
104
106
  status: response.status,
105
107
  }));
106
108
  }
107
- }), (0, operators_1.catchError)((error) => (0, rxjs_1.of)((0, transactionsViewReducer_1.fetchTransactionCategorizationFailure)({
108
- selectedPeriod,
109
- selectedTab,
110
- status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch Transaction Categorization REST API call errored out' +
111
- JSON.stringify(error)),
112
- }))));
109
+ }), (0, operators_1.catchError)((error) => {
110
+ const currentSearchString = state$.value.expenseAutomationTransactionsViewState
111
+ .transactionCategorizationView[selectedTab].uiState
112
+ .searchString;
113
+ if (currentSearchString !== requestSearchString) {
114
+ return rxjs_1.EMPTY;
115
+ }
116
+ return (0, rxjs_1.of)((0, transactionsViewReducer_1.fetchTransactionCategorizationFailure)({
117
+ selectedPeriod,
118
+ selectedTab,
119
+ status: (0, responsePayload_1.createZeniAPIStatus)('Unexpected Error', 'fetch Transaction Categorization REST API call errored out' +
120
+ JSON.stringify(error)),
121
+ }));
122
+ }));
113
123
  }))));
114
124
  exports.fetchTransactionCategorizationEpic = fetchTransactionCategorizationEpic;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.18-betaRD3",
3
+ "version": "5.1.18-betaRD4",
4
4
  "description": "Shared module between Web & Mobile containing required abstractions for state management, async network communication. ",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib/esm/index.js",