Skip to content

Commit 7fa157e

Browse files
committed
Do not show past meetups in upcoming events
1 parent bcba864 commit 7fa157e

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/app/(main)/community/events/get-all-events.ts

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,26 @@ export async function getAllEvents() {
4747

4848
for (const meetup of meetups) {
4949
const { next, prev } = meetup.node
50+
51+
// if next is in the past we treat it as past event
5052
if (next && new Date(next) < now) {
5153
pastEvents.push(meetup)
52-
} else {
53-
upcomingEvents.push(meetup)
54+
}
55+
// if prev is in the past it is obviously a past event
56+
else if (prev && new Date(prev) < now) {
5457
pastEvents.push({
55-
...meetup,
56-
date: prev,
58+
node: {
59+
...meetup.node,
60+
// we disregard .next, it's checked in nexdt if statement
61+
next: "",
62+
},
5763
})
5864
}
65+
66+
// if next is in the future, it is an upcoming event
67+
if (next && new Date(next) >= now) {
68+
upcomingEvents.push(meetup)
69+
}
5970
}
6071

6172
const getDate = (event: AnyEvent) => {

0 commit comments

Comments
 (0)