useEntities: drop X-Total-Count if it's less than the number of entities in the response (that doesn't make sense)

environments/review-drop-inval-givwvp/deployments/3096
Alex Gleason 2023-04-04 15:52:41 -05:00
rodzic 739062106b
commit 0c45889206
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -65,11 +65,12 @@ function useEntities<TEntity extends Entity>(
const schema = opts.schema || z.custom<TEntity>();
const entities = filteredArray(schema).parse(response.data);
const parsedCount = realNumberSchema.safeParse(response.headers['x-total-count']);
const totalCount = parsedCount.success ? parsedCount.data : undefined;
dispatch(entitiesFetchSuccess(entities, entityType, listKey, {
next: getNextLink(response),
prev: getPrevLink(response),
totalCount: parsedCount.success ? parsedCount.data : undefined,
totalCount: Number(totalCount) >= entities.length ? totalCount : undefined,
fetching: false,
fetched: true,
error: null,