Skip to content

Commit

Permalink
Merge pull request #181 from poap-xyz/release/v1.10.3
Browse files Browse the repository at this point in the history
Release v1.10.3
  • Loading branch information
jm42 authored Apr 16, 2024
2 parents f8223f3 + 1f1a5b2 commit 1c99b34
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
31 changes: 23 additions & 8 deletions netlify/edge-functions/images.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ function renderEventsImages(events, canvas, size, pos) {
export default async function handler(request, context) {
const eventIds = getEventIds(request.url)

let events
let eventMap
try {
events = await getEvents(eventIds)
eventMap = await getEvents(eventIds)
} catch (err) {
if (err?.response?.status === 404) {
return new Response(null, {
Expand All @@ -84,16 +84,31 @@ export default async function handler(request, context) {
})
}

const eventsLeft = Object.values(events)
const events = Object.values(eventMap)
.map((event) => ({ event, sort: Math.random() }))
.sort((a, b) => a.sort - b.sort)
.map(({ event }) => event)

const images = [
...renderEventsImages(eventsLeft.splice(0, 12), 512, 128, 0),
...renderEventsImages(eventsLeft.splice(0, 12), 256, 64, 128),
...renderEventsImages(eventsLeft.splice(0, 12), 128, 32, 192),
]
let images = []
if (events.length < 6) {
images = [
...renderEventsImages(events, 512, 224, 0),
]
} else if (events.length <= 8) {
images = [
...renderEventsImages(events, 512, 192, 0),
]
} else if (events.length < 12) {
images = [
...renderEventsImages(events, 512, 160, 0),
]
} else {
images = [
...renderEventsImages(events.splice(0, 12), 512, 128, 0),
...renderEventsImages(events.splice(0, 12), 256, 64, 128),
...renderEventsImages(events.splice(0, 12), 128, 32, 192),
]
}

return new ImageResponse(
(
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/poap-family",
"version": "1.10.2",
"version": "1.10.3",
"author": {
"name": "POAP",
"url": "https://poap.xyz"
Expand Down

0 comments on commit 1c99b34

Please sign in to comment.