Skip to content

Commit

Permalink
Fix homepage loading UX (#4935)
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw authored Oct 3, 2023
1 parent 209317f commit d38e696
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions packages/atlas/src/hooks/useInfiniteVideoGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ export const useInfiniteVideoGrid = <Query extends VideoInfiniteQueries>({
const firstLoadPlaceholders = firstLoad ? createPlaceholderData(columns * initialRowsToLoad) : []

const displayedItems = dataConnection?.edges.map((edge) => edge.node) || []
const itemsLeft = (dataConnection?.totalCount || 0) - (dataConnection?.edges?.length || 0)
const itemsToLoad = Math.min(itemsLeft, columns * 4)

const nextLoadPlaceholders = !dataConnection?.pageInfo.hasNextPage || false ? [] : createPlaceholderData(itemsToLoad)
const nextLoadPlaceholders = dataConnection?.pageInfo.hasNextPage ? createPlaceholderData(columns * 4) : []

return {
tiles: [...firstLoadPlaceholders, ...displayedItems, ...(loading ? nextLoadPlaceholders : [])],
Expand Down

0 comments on commit d38e696

Please sign in to comment.