gabrielguerrero / ngrx-traits

NGRX Traits is a library to help you compose and reuse state logic in your angular app. There is two versions, @ngrx-traits/signals supports ngrx-signals, and @ngrx-traits/{core, common} supports ngrx.
MIT License
44 stars 3 forks source link

Remote Pagination bug when last page has only 1 item #106

Closed gabrielguerrero closed 4 days ago

gabrielguerrero commented 1 week ago

There is a bug in withEntitiesRemotePagination , that makes the last page not render if it has only one item Example of a case that produces the error

   const Store = signalStore(
  withEntities({ entity, ollection: productsCollection }),
  withCallStatus({ ollection: productsCollection }),
  withEntitiesRemotePagination({
    entity,
    ollection: productsCollection,
    pageSize: 10,
    pagesToCache: 1,
  }),
  withEntitiesLoadingCall(
    ({ productsPagedRequest, productsFilter, productsSort }) => ({
      collection: productsCollection,
      fetchEntities: async () => {
        const res = await lastValueFrom(
          inject(ProductService).getProducts({
            search: productsFilter().search,
            skip: productsPagedRequest().startIndex,
            take: productsPagedRequest().size,
            sortAscending: productsSort().direction === "asc",
            sortColumn: productsSort().field,
          }),
        );
        return { entities: res.resultList, total: res.total };
      },
      mapError: (error) => (error as Error).message,
    }),
  ),
);
github-actions[bot] commented 1 week ago

:tada: This issue has been resolved in version 17.9.0-beta.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

github-actions[bot] commented 4 days ago

:tada: This issue has been resolved in version 17.9.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: