@zeniai/client-epic-state 5.1.18-betaRD2 → 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.
- package/lib/esm/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +29 -7
- package/lib/esm/view/expenseAutomationView/reducers/transactionsViewReducer.js +4 -0
- package/lib/view/expenseAutomationView/epics/transactionCategorization/fetchTransactionCategorizationEpic.js +28 -6
- package/lib/view/expenseAutomationView/reducers/transactionsViewReducer.js +4 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { from, of } from 'rxjs';
|
|
1
|
+
import { EMPTY, from, of } from 'rxjs';
|
|
2
2
|
import { catchError, filter, groupBy, mergeMap, switchMap } from 'rxjs/operators';
|
|
3
3
|
import { toString } from '../../../../commonStateTypes/timePeriod';
|
|
4
4
|
import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
|
|
@@ -16,6 +16,7 @@ groupBy((action) => action.payload.selectedTab), mergeMap((group$) => group$.pip
|
|
|
16
16
|
const { period, keepExistingListItems, selectedTab, refreshViewInBackground, } = action.payload;
|
|
17
17
|
const uiState = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTab].uiState;
|
|
18
18
|
const { pageToken, sortOrder, sortKey } = uiState;
|
|
19
|
+
const requestSearchString = uiState.searchString;
|
|
19
20
|
const currentTenant = getCurrentTenant(state$.value);
|
|
20
21
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
21
22
|
const queryParam = {
|
|
@@ -38,6 +39,19 @@ groupBy((action) => action.payload.selectedTab), mergeMap((group$) => group$.pip
|
|
|
38
39
|
return zeniAPI
|
|
39
40
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
40
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
|
+
}
|
|
41
55
|
if (isSuccessResponse(response) && response.data != null) {
|
|
42
56
|
const updateActions = [];
|
|
43
57
|
updateActions.push(updateTransactions(response.data.transactions, (value) => value.transaction_id, 'merge'));
|
|
@@ -89,10 +103,18 @@ groupBy((action) => action.payload.selectedTab), mergeMap((group$) => group$.pip
|
|
|
89
103
|
status: response.status,
|
|
90
104
|
}));
|
|
91
105
|
}
|
|
92
|
-
}), catchError((error) =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
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
|
+
}));
|
|
98
120
|
}))));
|
|
@@ -744,6 +744,10 @@ const expenseAutomationTransactionsView = createSlice({
|
|
|
744
744
|
'';
|
|
745
745
|
draft.transactionCategorizationView[selectedTab].uiState.pageToken = null;
|
|
746
746
|
draft.transactionCategorizationView[selectedTab].fetchState = 'Completed';
|
|
747
|
+
draft.transactionCategorizationView[selectedTab].refreshStatus = {
|
|
748
|
+
fetchState: 'Not-Started',
|
|
749
|
+
error: undefined,
|
|
750
|
+
};
|
|
747
751
|
draft.transactionCategorizationView[selectedTab].error = undefined;
|
|
748
752
|
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
|
|
749
753
|
undefined;
|
|
@@ -19,6 +19,7 @@ const fetchTransactionCategorizationEpic = (actions$, state$, zeniAPI) => action
|
|
|
19
19
|
const { period, keepExistingListItems, selectedTab, refreshViewInBackground, } = action.payload;
|
|
20
20
|
const uiState = expenseAutomationTransactionsViewState.transactionCategorizationView[selectedTab].uiState;
|
|
21
21
|
const { pageToken, sortOrder, sortKey } = uiState;
|
|
22
|
+
const requestSearchString = uiState.searchString;
|
|
22
23
|
const currentTenant = (0, tenantSelector_1.getCurrentTenant)(state$.value);
|
|
23
24
|
const selectedPeriod = selectedPeriodByTenantId[currentTenant.tenantId];
|
|
24
25
|
const queryParam = {
|
|
@@ -41,6 +42,19 @@ const fetchTransactionCategorizationEpic = (actions$, state$, zeniAPI) => action
|
|
|
41
42
|
return zeniAPI
|
|
42
43
|
.getJSON(`${zeniAPI.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(queryParam))}`)
|
|
43
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
|
+
}
|
|
44
58
|
if ((0, responsePayload_1.isSuccessResponse)(response) && response.data != null) {
|
|
45
59
|
const updateActions = [];
|
|
46
60
|
updateActions.push((0, transactionReducer_1.updateTransactions)(response.data.transactions, (value) => value.transaction_id, 'merge'));
|
|
@@ -92,11 +106,19 @@ const fetchTransactionCategorizationEpic = (actions$, state$, zeniAPI) => action
|
|
|
92
106
|
status: response.status,
|
|
93
107
|
}));
|
|
94
108
|
}
|
|
95
|
-
}), (0, operators_1.catchError)((error) =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
+
}));
|
|
101
123
|
}))));
|
|
102
124
|
exports.fetchTransactionCategorizationEpic = fetchTransactionCategorizationEpic;
|
|
@@ -751,6 +751,10 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
|
|
|
751
751
|
'';
|
|
752
752
|
draft.transactionCategorizationView[selectedTab].uiState.pageToken = null;
|
|
753
753
|
draft.transactionCategorizationView[selectedTab].fetchState = 'Completed';
|
|
754
|
+
draft.transactionCategorizationView[selectedTab].refreshStatus = {
|
|
755
|
+
fetchState: 'Not-Started',
|
|
756
|
+
error: undefined,
|
|
757
|
+
};
|
|
754
758
|
draft.transactionCategorizationView[selectedTab].error = undefined;
|
|
755
759
|
draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
|
|
756
760
|
undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeniai/client-epic-state",
|
|
3
|
-
"version": "5.1.18-
|
|
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",
|