Skip to content

Commit

Permalink
Merge pull request #162 from poap-xyz/release/1.8.7
Browse files Browse the repository at this point in the history
Release 1.8.7
  • Loading branch information
jm42 authored Mar 31, 2024
2 parents 6baeca0 + 88d672a commit 5801290
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
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.8.6",
"version": "1.8.7",
"author": {
"name": "POAP",
"url": "https://poap.xyz"
Expand Down
18 changes: 18 additions & 0 deletions src/loaders/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ async function putEventAndOwners(event, owners) {
},
body: JSON.stringify({ event, owners }),
})
if (response.status === 400) {
throw new Error(`Event ${event.id} save failed: incorrect data given`)
}
if (response.status === 503) {
throw new Error(`Event ${event.id} save failed: server cannot fetch data`)
}
if (response.status !== 200 && response.status !== 201) {
throw new Error(`Event ${event.id} save failed (status ${response.status})`)
}
Expand Down Expand Up @@ -104,6 +110,12 @@ async function patchEvents(events) {
},
body: JSON.stringify(events),
})
if (response.status === 400) {
throw new Error(`Events save failed: incorrect data given`)
}
if (response.status === 503) {
throw new Error(`Events save failed: server cannot fetch data`)
}
if (response.status !== 200 && response.status !== 201) {
throw new Error(`Events save failed (status ${response.status})`)
}
Expand Down Expand Up @@ -331,6 +343,12 @@ async function putEventOwners(eventId, owners) {
},
body: JSON.stringify(owners),
})
if (response.status === 400) {
throw new Error(`Event ${eventId} save owners failed: incorrect data given`)
}
if (response.status === 503) {
throw new Error(`Event ${eventId} save owners failed: server cannot fetch data`)
}
if (response.status !== 200 && response.status !== 201) {
throw new Error(`Event ${eventId} save owners failed (status ${response.status})`)
}
Expand Down
8 changes: 6 additions & 2 deletions src/loaders/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ async function eventLoader({ params, request }) {
const owners = tokens.map((token) => token.owner.id)
const uniqueOwners = owners.filter((value, index, all) => all.indexOf(value) === index)
const filteredOwners = uniqueOwners.filter((owner) => !IGNORED_OWNERS.includes(owner))
putEventAndOwners(event, filteredOwners)
putEventAndOwners(event, filteredOwners).catch((err) => {
console.error(err)
})
return {
event,
owners: filteredOwners,
Expand Down Expand Up @@ -305,7 +307,9 @@ async function eventsLoader({ params, request }) {
})
}
}
patchEvents(Object.values(events))
patchEvents(Object.values(events)).catch((err) => {
console.error(err)
})
return events
}

Expand Down
10 changes: 4 additions & 6 deletions src/pages/Event.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,10 @@ function Event() {
)
setCaching(true)
setCachingError(null)
Promise
.all([
patchEvents(Object.values(eventsProcessed)),
putEventInCommon(event.id, inCommonProcessed),
])
.then(
patchEvents(Object.values(eventsProcessed)).catch((err) => {
console.error(err)
})
putEventInCommon(event.id, inCommonProcessed).then(
() => {
setCaching(false)
setCachedTs(Math.trunc(Date.now() / 1000))
Expand Down
18 changes: 10 additions & 8 deletions src/pages/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ function Events() {
const newOwners = [...new Set(eventOwnerTokens.map((token) => token.owner.id))]
const newOwnersFilters = newOwners.filter((owner) => !IGNORED_OWNERS.includes(owner))
setOwners((prevOwners) => ({ ...prevOwners, [eventId]: newOwnersFilters }))
putEventOwners(eventId, newOwnersFilters)
putEventOwners(eventId, newOwnersFilters).catch((err) => {
console.error(err)
})
return Promise.resolve()
}
return Promise.reject(new Error(`Tokens for drop '${eventId}' missing`))
Expand Down Expand Up @@ -164,7 +166,9 @@ function Events() {
if (Array.isArray(eventOwnerTokens)) {
const newOwners = [...new Set(eventOwnerTokens.map((token) => token.owner.id))]
setOwners((prevOwners) => ({ ...prevOwners, [eventId]: newOwners }))
putEventOwners(eventId, newOwners)
putEventOwners(eventId, newOwners).catch((err) => {
console.error(err)
})
} else {
return Promise.reject(new Error(`Tokens for drop '${eventId}' missing`))
}
Expand Down Expand Up @@ -528,12 +532,10 @@ function Events() {
)
removeErrors(eventId)
setLoading((alsoLoading) => ({ ...alsoLoading, [eventId]: LOADING_CACHING }))
Promise
.all([
patchEvents(Object.values(eventsProcessed)),
putEventInCommon(eventId, inCommonProcessed),
])
.then(
patchEvents(Object.values(eventsProcessed)).catch((err) => {
console.error(err)
})
putEventInCommon(eventId, inCommonProcessed).then(
() => {
setEventData((prevEventData) => ({
...prevEventData,
Expand Down

0 comments on commit 5801290

Please sign in to comment.