]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/rest/component-pagination.model.ts
Merge branch 'release/2.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / rest / component-pagination.model.ts
index 0b8ecc318bd7c866dfaa9d547f39c9bd93f8b573..bcb73ed0f4a030d3019031e3d36f3ea3e2b9d831 100644 (file)
@@ -1,5 +1,18 @@
 export interface ComponentPagination {
   currentPage: number
   itemsPerPage: number
-  totalItems?: number
+  totalItems: number
+}
+
+export type ComponentPaginationLight = Omit<ComponentPagination, 'totalItems'>
+
+export function hasMoreItems (componentPagination: ComponentPagination) {
+  // No results
+  if (componentPagination.totalItems === 0) return false
+
+  // Not loaded yet
+  if (!componentPagination.totalItems) return true
+
+  const maxPage = componentPagination.totalItems / componentPagination.itemsPerPage
+  return maxPage > componentPagination.currentPage
 }