Skip to content

Commit

Permalink
Avoid duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
WRadoslaw committed Mar 7, 2024
1 parent 576a05d commit 547bc0a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/atlas/src/hooks/useInfiniteVideoGrid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useInfiniteVideoGrid = <Query extends VideoInfiniteQueries>({
const { data, loading, fetchMore } = useApolloQuery<Query>(query, {
...options,
notifyOnNetworkStatusChange: true,
skip: !columns,
skip: options?.skip || !columns,
variables: {
...variables,
first: columns * initialRowsToLoad,
Expand Down
15 changes: 9 additions & 6 deletions packages/atlas/src/views/viewer/HomeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,32 @@ const useHomeVideos = () => {
...publicCryptoVideoFilter,
orionLanguage_in: undefined,
includeInHomeFeed_eq: true,
isShort_not_eq: undefined,
},
skipVideoIds: ['-1'],
},
})

const avoidIds = data?.dumbPublicFeedVideos ? data.dumbPublicFeedVideos?.map((video) => video.id) : undefined
const { columns, fetchMore, pageInfo, tiles } = useInfiniteVideoGrid({
query: GetBasicVideosConnectionLightweightDocument,
variables: {
where: publicCryptoVideoFilter,
where: {
...publicCryptoVideoFilter,
id_not_in: avoidIds,
},
orderBy: VideoOrderByInput.VideoRelevanceDesc,
first: 1,
},
options: {
skip: !avoidIds,
},
})

const firstLoad = !data?.dumbPublicFeedVideos && loading
const firstLoadPlaceholders = firstLoad ? createPlaceholderData(columns * initialRowsToLoad) : []

const displayedItems = [...(data?.dumbPublicFeedVideos || []), ...(tiles || [])]
const nextLoadPlaceholders = createPlaceholderData(columns * 4)

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

0 comments on commit 547bc0a

Please sign in to comment.