@zeniai/client-epic-state 5.1.18-betaRD1 → 5.1.18-betaRD2

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.
@@ -164,23 +164,25 @@ const expenseAutomationTransactionsView = createSlice({
164
164
  searchString;
165
165
  }
166
166
  draft.transactionCategorizationView[selectedTab].error = undefined;
167
- // Reset list when we change the sort order and fetch list again
168
- if (resetListItems === true) {
169
- const monthYearPeriod = {
170
- month: period.start.month,
171
- year: period.start.year,
172
- };
173
- const periodId = toMonthYearPeriodId(monthYearPeriod);
174
- const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
175
- .transactionIdsBySelectedPeriod[periodId] ?? [];
176
- // When starting a non-empty search, snapshot the current full dataset
177
- // so clearing the search can restore instantly without an API round-trip.
178
- // Only save the snapshot when there are rows to restore; skip for tabs
179
- // that have never been loaded (empty list no useful snapshot).
180
- if (searchString !== undefined &&
181
- searchString !== '' &&
182
- transactionIdsBySelectedPeriod.length > 0) {
183
- const snapshot = {
167
+ const monthYearPeriod = {
168
+ month: period.start.month,
169
+ year: period.start.year,
170
+ };
171
+ const periodId = toMonthYearPeriodId(monthYearPeriod);
172
+ const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
173
+ .transactionIdsBySelectedPeriod[periodId] ?? [];
174
+ // Snapshot before any list mutation so clearing the search restores
175
+ // instantly without an API round-trip — for BOTH active and synced tabs.
176
+ // Active-tab search dispatches resetListItems=false, so this must live
177
+ // outside the resetListItems block. fullDatasetSnapshot == null prevents
178
+ // overwriting the original snapshot on search refinement ('ama'→'amazon').
179
+ if (searchString !== undefined &&
180
+ searchString !== '' &&
181
+ transactionIdsBySelectedPeriod.length > 0 &&
182
+ draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot ==
183
+ null) {
184
+ draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
185
+ {
184
186
  parentTotalCount: draft.parentTotalCountByTab[selectedTab][periodId],
185
187
  periodId,
186
188
  totalCount: draft.transactionCategorizationView[selectedTab].uiState
@@ -191,16 +193,16 @@ const expenseAutomationTransactionsView = createSlice({
191
193
  .transactionReviewLocalDataById,
192
194
  },
193
195
  };
194
- draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
195
- snapshot;
196
- }
196
+ }
197
+ // Reset list when we change the sort order and fetch list again
198
+ if (resetListItems === true) {
197
199
  transactionIdsBySelectedPeriod.forEach((transactionId) => {
198
200
  delete draft.transactionCategorizationView[selectedTab]
199
201
  .transactionReviewLocalDataById[transactionId];
200
202
  });
201
203
  draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds =
202
204
  draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds.filter((selectedCheckBoxTransactionId) => transactionIdsBySelectedPeriod.includes(selectedCheckBoxTransactionId));
203
- draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[toMonthYearPeriodId(monthYearPeriod)] = [];
205
+ draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[periodId] = [];
204
206
  draft.transactionCategorizationView[selectedTab].refreshStatus = {
205
207
  fetchState: 'Not-Started',
206
208
  error: undefined,
@@ -171,23 +171,25 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
171
171
  searchString;
172
172
  }
173
173
  draft.transactionCategorizationView[selectedTab].error = undefined;
174
- // Reset list when we change the sort order and fetch list again
175
- if (resetListItems === true) {
176
- const monthYearPeriod = {
177
- month: period.start.month,
178
- year: period.start.year,
179
- };
180
- const periodId = (0, timePeriod_1.toMonthYearPeriodId)(monthYearPeriod);
181
- const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
182
- .transactionIdsBySelectedPeriod[periodId] ?? [];
183
- // When starting a non-empty search, snapshot the current full dataset
184
- // so clearing the search can restore instantly without an API round-trip.
185
- // Only save the snapshot when there are rows to restore; skip for tabs
186
- // that have never been loaded (empty list no useful snapshot).
187
- if (searchString !== undefined &&
188
- searchString !== '' &&
189
- transactionIdsBySelectedPeriod.length > 0) {
190
- const snapshot = {
174
+ const monthYearPeriod = {
175
+ month: period.start.month,
176
+ year: period.start.year,
177
+ };
178
+ const periodId = (0, timePeriod_1.toMonthYearPeriodId)(monthYearPeriod);
179
+ const transactionIdsBySelectedPeriod = draft.transactionCategorizationView[selectedTab]
180
+ .transactionIdsBySelectedPeriod[periodId] ?? [];
181
+ // Snapshot before any list mutation so clearing the search restores
182
+ // instantly without an API round-trip — for BOTH active and synced tabs.
183
+ // Active-tab search dispatches resetListItems=false, so this must live
184
+ // outside the resetListItems block. fullDatasetSnapshot == null prevents
185
+ // overwriting the original snapshot on search refinement ('ama'→'amazon').
186
+ if (searchString !== undefined &&
187
+ searchString !== '' &&
188
+ transactionIdsBySelectedPeriod.length > 0 &&
189
+ draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot ==
190
+ null) {
191
+ draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
192
+ {
191
193
  parentTotalCount: draft.parentTotalCountByTab[selectedTab][periodId],
192
194
  periodId,
193
195
  totalCount: draft.transactionCategorizationView[selectedTab].uiState
@@ -198,16 +200,16 @@ const expenseAutomationTransactionsView = (0, toolkit_1.createSlice)({
198
200
  .transactionReviewLocalDataById,
199
201
  },
200
202
  };
201
- draft.transactionCategorizationView[selectedTab].fullDatasetSnapshot =
202
- snapshot;
203
- }
203
+ }
204
+ // Reset list when we change the sort order and fetch list again
205
+ if (resetListItems === true) {
204
206
  transactionIdsBySelectedPeriod.forEach((transactionId) => {
205
207
  delete draft.transactionCategorizationView[selectedTab]
206
208
  .transactionReviewLocalDataById[transactionId];
207
209
  });
208
210
  draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds =
209
211
  draft.transactionCategorizationView[selectedTab].selectedCheckBoxTransactionIds.filter((selectedCheckBoxTransactionId) => transactionIdsBySelectedPeriod.includes(selectedCheckBoxTransactionId));
210
- draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[(0, timePeriod_1.toMonthYearPeriodId)(monthYearPeriod)] = [];
212
+ draft.transactionCategorizationView[selectedTab].transactionIdsBySelectedPeriod[periodId] = [];
211
213
  draft.transactionCategorizationView[selectedTab].refreshStatus = {
212
214
  fetchState: 'Not-Started',
213
215
  error: undefined,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeniai/client-epic-state",
3
- "version": "5.1.18-betaRD1",
3
+ "version": "5.1.18-betaRD2",
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",