Skip to content

Commit

Permalink
display all drops, even if they belong to the same collection
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasMahe committed Feb 5, 2024
1 parent 0c79622 commit df223dc
Showing 1 changed file with 2 additions and 36 deletions.
38 changes: 2 additions & 36 deletions pages/drops.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,42 +28,8 @@ const DropsPage: NextPage<Props> = ({ now }) => {
const { data, refetch } = useFetchDropsQuery({
variables: { now: date, limit, offset },
})

// only keep one active drop per collection
const activeDrops = useMemo(() => {
return data?.active?.nodes.filter(
(drop, i, arr) =>
arr.findIndex(
(x) =>
x.collection.chainId === drop.collection.chainId &&
x.collection.address === drop.collection.address,
) === i,
)
}, [data?.active?.nodes])

const endedDrops = useMemo(() => {
return (
data?.ended?.nodes
// remove drops with a collection already in an active drop
.filter(
(drop) =>
!data.active?.nodes?.some(
(x) =>
x.collection.chainId === drop.collection.chainId &&
x.collection.address === drop.collection.address,
),
)
// only keep one active drop per collection
.filter(
(drop, i, arr) =>
arr.findIndex(
(x) =>
x.collection.chainId === drop.collection.chainId &&
x.collection.address === drop.collection.address,
) === i,
)
)
}, [data?.active?.nodes, data?.ended?.nodes])
const activeDrops = data?.active?.nodes
const endedDrops = data?.ended?.nodes

const onCountdownEnd = useCallback(async () => await refetch(), [refetch])

Expand Down

0 comments on commit df223dc

Please sign in to comment.