@zeniai/client-epic-state 4.19.84-betaVR2 → 4.19.84-betaVR4

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.
@@ -6,7 +6,7 @@ import { createZeniAPIStatus } from '../../../../responsePayload';
6
6
  import { filterBatchListItemsForBatchDetailsFetch } from '../../payload/missingReceiptsPayload';
7
7
  import { fetchMoreBatchDetails, fetchMoreBatchDetailsComplete, fetchMoreBatchDetailsFailure, } from '../../reducers/missingReceiptsViewReducer';
8
8
  import { fetchBatchDetailsByIds } from './fetchMultipleBatchDetailsEpic';
9
- const MORE_BATCH_PAGE_SIZE = 1;
9
+ const MORE_BATCH_PAGE_SIZE = 5;
10
10
  export const fetchMoreBatchDetailsEpic = (actions$, state$, zeniAPI) => actions$.pipe(filter(fetchMoreBatchDetails.match),
11
11
  /** One page at a time — avoids duplicate loads if IO + scroll fallback both fire. */
12
12
  exhaustMap(() => {
@@ -4,7 +4,7 @@ import { updateTransactions } from '../../../../entity/transaction/transactionRe
4
4
  import { createZeniAPIStatus, isSuccessResponse, } from '../../../../responsePayload';
5
5
  import { extractTransactionPayloadsFromBatchFiles, filterBatchListItemsForBatchDetailsFetch, isBatchDetailsApiStatusCompleted, shouldFetchBatchDetailsForBatchId, toBatchDetails, } from '../../payload/missingReceiptsPayload';
6
6
  import { batchDetailFetchFailed, fetchBulkUploadBatchDetails, fetchBulkUploadBatchesSuccess, fetchMoreBatchDetailsComplete, setInitialBatchDetailsLoading, storeBatchDetails, } from '../../reducers/missingReceiptsViewReducer';
7
- const INITIAL_BATCH_PAGE_SIZE = 1;
7
+ const INITIAL_BATCH_PAGE_SIZE = 5;
8
8
  export function fetchBatchDetailsByIds(batchIds, zeniAPI) {
9
9
  if (batchIds.length === 0) {
10
10
  return EMPTY;
@@ -1,4 +1,4 @@
1
- import { from, merge, of } from 'rxjs';
1
+ import { EMPTY, from, merge, of } from 'rxjs';
2
2
  import { catchError, debounceTime, filter, mergeMap, switchMap } from 'rxjs/operators';
3
3
  import { convertToPeriod } from '../../../../commonStateTypes/timePeriod';
4
4
  import { getCurrentTenant } from '../../../../entity/tenant/tenantSelector';
@@ -16,9 +16,14 @@ export const MANUAL_TRANSACTION_SEARCH_AUTO_CATEGORIZED = false;
16
16
  export const searchTransactionsForManualMatchEpic = (actions$, state$, zeniAPI) => {
17
17
  const searchActions$ = actions$.pipe(filter(searchTransactionsForManualMatch.match));
18
18
  const pagination$ = searchActions$.pipe(filter((a) => a.payload.pageToken != null));
19
- const newSearch$ = searchActions$.pipe(filter((a) => a.payload.pageToken == null), debounceTime(300));
20
- return merge(pagination$, newSearch$).pipe(switchMap((action) => {
19
+ /** Clears: no debounce so switchMap cancels in-flight HTTP from the previous query immediately. */
20
+ const newSearchClear$ = searchActions$.pipe(filter((a) => a.payload.pageToken == null && a.payload.query.trim() === ''));
21
+ const newSearchDebounced$ = searchActions$.pipe(filter((a) => a.payload.pageToken == null && a.payload.query.trim() !== ''), debounceTime(300));
22
+ return merge(pagination$, newSearchClear$, newSearchDebounced$).pipe(switchMap((action) => {
21
23
  const { query, pageToken } = action.payload;
24
+ if (pageToken == null && query.trim() === '') {
25
+ return EMPTY;
26
+ }
22
27
  const state = state$.value;
23
28
  const { expenseAutomationViewState: { selectedPeriodByTenantId }, expenseAutomationMissingReceiptsViewState: { bulkUpload: { manualSearch, sortKey, sortOrder }, }, } = state;
24
29
  const currentTenant = getCurrentTenant(state);
@@ -352,7 +352,7 @@ const expenseAutomationMissingReceiptsView = createSlice({
352
352
  if (originalStatus === 'no_match') {
353
353
  details.summary.noMatch = Math.max(0, details.summary.noMatch - 1);
354
354
  }
355
- else {
355
+ else if (originalStatus === 'un_matched') {
356
356
  details.summary.possibleMatches = Math.max(0, details.summary.possibleMatches - 1);
357
357
  }
358
358
  }
@@ -384,6 +384,16 @@ const expenseAutomationMissingReceiptsView = createSlice({
384
384
  reducer(draft, action) {
385
385
  const { query, pageToken } = action.payload;
386
386
  const isLoadMore = pageToken != null;
387
+ const trimmed = query.trim();
388
+ /**
389
+ * Cleared input: reset fully (no In-Progress) so we never show a loader with stale rows,
390
+ * and the epic can cancel any in-flight search via switchMap without a debounce delay.
391
+ */
392
+ if (!isLoadMore && trimmed === '') {
393
+ draft.bulkUpload.manualSearch = initialBulkUploadState.manualSearch;
394
+ draft.bulkUpload.manualSearchUiResetKey += 1;
395
+ return;
396
+ }
387
397
  draft.bulkUpload.manualSearch.searchQuery = query;
388
398
  if (isLoadMore) {
389
399
  draft.bulkUpload.manualSearch.isLoadingMore = true;