From 4c645041cab40491f820f00f9e48d82ec6db6e2e Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:06:59 -0300 Subject: [PATCH 01/11] Load drops and collectors force --- src/hooks/useEventsOwnersAndMetrics.ts | 118 +++++----------- src/loaders/api.ts | 179 +------------------------ src/loaders/drop.ts | 3 +- src/loaders/event.ts | 92 +++---------- src/models/api.ts | 9 +- src/models/event.ts | 18 --- src/pages/Events.tsx | 9 +- src/utils/date.ts | 4 - 8 files changed, 56 insertions(+), 376 deletions(-) diff --git a/src/hooks/useEventsOwnersAndMetrics.ts b/src/hooks/useEventsOwnersAndMetrics.ts index fb22336..a697fe6 100644 --- a/src/hooks/useEventsOwnersAndMetrics.ts +++ b/src/hooks/useEventsOwnersAndMetrics.ts @@ -2,13 +2,11 @@ import { useCallback, useState } from 'react' import { filterInvalidOwners } from 'models/address' import { DropMetrics } from 'models/drop' import { AbortedError } from 'models/error' -import { EventAndOwners } from 'models/api' import { fetchCollectorsByDrops, fetchDropsCollectors } from 'loaders/collector' import { fetchDropMetrics, fetchDropsMetrics } from 'loaders/drop' -import { getEventAndOwners } from 'loaders/api' import { fillNull } from 'utils/object' -function useEventsOwnersAndMetrics(eventIds: number[], expiryDates: Record, force: boolean = false): { +function useEventsOwnersAndMetrics(eventIds: number[]): { completedEventsOwnersAndMetrics: boolean loadingEventsOwnersAndMetrics: boolean loadingOwnersAndMetricsEvents: Record @@ -111,45 +109,6 @@ function useEventsOwnersAndMetrics(eventIds: number[], expiryDates: Record { - removeError(eventId) - addLoading(eventId) - let eventAndOwners: EventAndOwners | null = null - try { - eventAndOwners = await getEventAndOwners( - eventId, - abortSignal, - /*includeDescription*/false, - /*includeMetrics*/true, - /*refresh*/false - ) - } catch (err: unknown) { - removeLoading(eventId) - if (!(err instanceof AbortedError)) { - addError(eventId, new Error( - 'Could not fetch drop and collectors', - { cause: err } - )) - } - return - } - removeLoading(eventId) - if (eventAndOwners != null) { - updateEventOwners(eventId, eventAndOwners.owners) - if (eventAndOwners.metrics) { - updateEventMetrics(eventId, eventAndOwners.metrics) - } - } else { - addError( - eventId, - new Error('Could not fetch drop and collectors') - ) - } - }, - [] - ) - const loadOwnersAndMetrics = useCallback( async (eventId: number, abortSignal: AbortSignal) => { removeError(eventId) @@ -219,51 +178,38 @@ function useEventsOwnersAndMetrics(eventIds: number[], expiryDates: Record { r(undefined) }) - for (const eventId of eventIds) { - promise = promise.then( - () => loadOwnersAndMetrics(eventId, controllers[eventId].signal) - ) - } - promise.finally(() => { - setCompleted(true) - }) - } else { - setLoadingCache(true) - controller = new AbortController() - Promise.all([ - fetchCollectorsByDrops(eventIds, controller.signal), - fetchDropsMetrics(eventIds, controller.signal), - ]).then(([eventsOwners, eventsMetrics]) => { - updateEventsOwners( - fillNull( - eventsOwners, - eventIds.map((eventId) => String(eventId)), - [] - ) + setLoadingCache(true) + controller = new AbortController() + Promise.all([ + fetchCollectorsByDrops(eventIds, controller.signal), + fetchDropsMetrics(eventIds, controller.signal), + ]).then(([eventsOwners, eventsMetrics]) => { + updateEventsOwners( + fillNull( + eventsOwners, + eventIds.map((eventId) => String(eventId)), + [] ) - updateEventsMetrics(eventsMetrics) - setLoadingCache(false) + ) + updateEventsMetrics(eventsMetrics) + setLoadingCache(false) + setCompleted(true) + }).catch((err: unknown) => { + setLoadingCache(false) + if (err instanceof AbortedError) { setCompleted(true) - }).catch((err: unknown) => { - setLoadingCache(false) - if (err instanceof AbortedError) { - setCompleted(true) - } else { - console.error(err) - let promise = new Promise((r) => { r(undefined) }) - for (const eventId of eventIds) { - promise = promise.then(() => force - ? loadOwnersAndMetrics(eventId, controllers[eventId].signal) - : loadCachedOwnersAndMetrics(eventId, controllers[eventId].signal)) - } - promise.finally(() => { - setCompleted(true) - }) + } else { + console.error(err) + let promise = new Promise((r) => { r(undefined) }) + for (const eventId of eventIds) { + promise = promise.then(() => + loadOwnersAndMetrics(eventId, controllers[eventId].signal)) } - }) - } + promise.finally(() => { + setCompleted(true) + }) + } + }) return () => { if (controller) { controller.abort() @@ -280,8 +226,6 @@ function useEventsOwnersAndMetrics(eventIds: number[], expiryDates: Record void { removeError(eventId) const controller = new AbortController() - loadCachedOwnersAndMetrics(eventId, controller.signal) + loadOwnersAndMetrics(eventId, controller.signal) return () => { controller.abort() } diff --git a/src/loaders/api.ts b/src/loaders/api.ts index 0141669..723c683 100644 --- a/src/loaders/api.ts +++ b/src/loaders/api.ts @@ -7,106 +7,11 @@ import { CachedEvent, Feedback, EventsInCommon, - EventAndOwners, } from 'models/api' -import { parseDrop, parseDropMetrics, Drop } from 'models/drop' +import { parseDrop, Drop } from 'models/drop' import { AbortedError, HttpError } from 'models/error' import { DownloadProgress } from 'models/http' -export async function getEventAndOwners( - eventId: number, - abortSignal: AbortSignal, - includeDescription: boolean = false, - includeMetrics: boolean = true, - refresh: boolean = false, -): Promise { - if (!FAMILY_API_KEY) { - throw new Error( - `Drop ${eventId} and owners could not be fetched, ` + - `configure Family API key` - ) - } - - let response: Response - - try { - response = await fetch( - `${FAMILY_API_URL}/event/${eventId}?` + - `description=${encodeURIComponent(includeDescription)}&` + - `metrics=${encodeURIComponent(includeMetrics)}` + - `${refresh ? '&refresh=true' : ''}`, - { - signal: abortSignal instanceof AbortSignal ? abortSignal : undefined, - headers: { - 'x-api-key': FAMILY_API_KEY, - }, - } - ) - } catch (err: unknown) { - if (err instanceof Error && err.name === 'AbortError') { - throw new AbortedError(`Fetch drop ${eventId} aborted`, { cause: err }) - } - throw new Error( - `Cannot fetch drop ${eventId}: ` + - `response was not success (network error)`, - { cause: err } - ) - } - - if (response.status === 404) { - return null - } - - if (response.status !== 200) { - throw new HttpError( - `Drop ${eventId} failed to fetch (status ${response.status})`, - { status: response.status } - ) - } - - const body: unknown = await response.json() - - if ( - body == null || - typeof body !== 'object' || - !('event' in body) || - body.event == null || - typeof body.event !== 'object' || - !('owners' in body) || - body.owners == null || - !Array.isArray(body.owners) || - !('ts' in body) || - body.ts == null || - typeof body.ts !== 'number' - ) { - throw new Error(`Malformed drop and owners (type ${typeof body})`) - } - - if (!includeMetrics) { - return { - event: parseDrop(body.event, includeDescription), - owners: body.owners, - ts: body.ts, - metrics: null, - } - } - - if ( - !('metrics' in body) || - body.metrics == null || - typeof body.metrics !== 'object' - ) { - throw new Error(`Malformed drop metrics (type ${typeof body})`) - } - - return { - event: parseDrop(body.event, includeDescription), - owners: body.owners, - ts: body.ts, - metrics: parseDropMetrics(body.metrics), - } -} - export async function getInCommonEvents( eventId: number, abortSignal: AbortSignal, @@ -620,88 +525,6 @@ export async function getLastEvents( } } -export async function getEvents( - eventIds: number[], - abortSignal?: AbortSignal, -): Promise> { - if (!FAMILY_API_KEY) { - throw new Error( - `Drops (${eventIds.length}) could not be fetched, ` + - `configure Family API key` - ) - } - - let response: Response - - try { - response = await fetch( - `${FAMILY_API_URL}/events` + - `/${eventIds.map((eventId) => encodeURIComponent(eventId)).join(',')}`, - { - signal: abortSignal instanceof AbortSignal ? abortSignal : null, - headers: { - 'x-api-key': FAMILY_API_KEY, - }, - } - ) - } catch (err: unknown) { - if (err instanceof Error && err.name === 'AbortError') { - throw new AbortedError(`Fetch drops aborted`, { cause: err }) - } - throw new Error( - `Cannot fetch drops: response was not success (network error)`, - { cause: err } - ) - } - - if (response.status !== 200) { - let message: string = 'Unknown error' - try { - const data = await response.json() - if ( - data != null && - typeof data === 'object' && - 'message' in data && - data.message != null && - typeof data.message === 'string' - ) { - message = data.message - } - } catch (err: unknown) { - console.error(err) - } - - if (message) { - throw new HttpError( - `Drops (${eventIds.length}) failed to fetch ` + - `(status ${response.status}): ${message}`, - { status: response.status } - ) - } - - throw new HttpError( - `Drops (${eventIds.length}) failed to fetch ` + - `(status ${response.status})`, - { status: response.status } - ) - } - - const body: unknown = await response.json() - - if (body == null || typeof body !== 'object') { - throw new Error(`Malformed drops (type ${typeof body})`) - } - - return Object.fromEntries( - Object.entries(body).map( - ([eventId, event]) => [ - eventId, - parseDrop(event, /*includeDescription*/false), - ] - ) - ) -} - export async function auth(passphrase: string): Promise { const response = await fetch(`${FAMILY_API_URL}/auth`, { method: 'POST', diff --git a/src/loaders/drop.ts b/src/loaders/drop.ts index 6f93265..ea6f28f 100644 --- a/src/loaders/drop.ts +++ b/src/loaders/drop.ts @@ -89,6 +89,7 @@ export async function searchDrops( export async function fetchDropsOrErrors( dropIds: number[], + includeDescription: boolean, limit: number = Math.min(DEFAULT_DROP_LIMIT, DEFAULT_COMPASS_LIMIT), ): Promise<[ Record, @@ -107,7 +108,7 @@ export async function fetchDropsOrErrors( try { const drops = await queryManyCompass( 'drops', - (data: unknown): Drop => parseDrop(data, /*includeDescription*/false), + (data: unknown): Drop => parseDrop(data, includeDescription), ` query FetchDrops($dropIds: [Int!]) { drops(where: { id: { _in: $dropIds } }) { diff --git a/src/loaders/event.ts b/src/loaders/event.ts index a7c4035..4d0d2c4 100644 --- a/src/loaders/event.ts +++ b/src/loaders/event.ts @@ -1,12 +1,9 @@ import { parseEventIds } from 'models/event' -import { Drop } from 'models/drop' import { HttpError } from 'models/error' -import { getEventAndOwners, getEvents } from 'loaders/api' import { fetchDrop, fetchDropMetrics, fetchDropsOrErrors } from 'loaders/drop' import { fetchDropsCollectors } from 'loaders/collector' -export async function eventLoader({ params, request }) { - const force = new URL(request.url).searchParams.get('force') === 'true' +export async function eventLoader({ params }) { const dropId = parseInt(String(params.eventId)) if (isNaN(dropId)) { @@ -16,26 +13,6 @@ export async function eventLoader({ params, request }) { }) } - try { - const eventAndOwners = await getEventAndOwners( - dropId, - /*abortSignal*/undefined, - /*includeDescription*/true, - /*includeMetrics*/true, - /*refresh*/force - ) - if (eventAndOwners != null) { - return { - event: eventAndOwners.event, - owners: eventAndOwners.owners, - ts: eventAndOwners.ts, - metrics: eventAndOwners.metrics, - } - } - } catch (err: unknown) { - console.error(err) - } - const event = await fetchDrop(dropId, /*includeDescription*/true) if (!event) { @@ -71,7 +48,7 @@ export async function eventLoader({ params, request }) { } } -export async function eventsLoader({ params, request }) { +export async function eventsLoader({ params }) { const eventIds = parseEventIds(params.eventIds) if (eventIds.length === 0) { @@ -101,73 +78,45 @@ export async function eventsLoader({ params, request }) { }) } - const force = new URL(request.url).searchParams.get('force') === 'true' - let events: Record - let notFoundEventIds: number[] | undefined - - if (!force) { - try { - events = await getEvents(eventIds) - } catch (err: unknown) { - console.error(err) - } - if (events) { - notFoundEventIds = [] - - for (const eventId of eventIds) { - if (!(eventId in events)) { - notFoundEventIds.push(eventId) - } - } - - if (notFoundEventIds.length === 0) { - return events - } - } - } - - if (!events) { - events = {} - } - - const [freshEvents, errors] = await fetchDropsOrErrors( - notFoundEventIds ?? eventIds + const [drops, errors] = await fetchDropsOrErrors( + eventIds, + /*includeDescription*/false ) if (Object.keys(errors).length > 0) { - const errorsByEventId = Object.assign({}, errors) - const eventsNotFound = await Promise.allSettled( + const errorsByDropId = Object.assign({}, errors) + const dropsNotFound = await Promise.allSettled( Object.entries(errors) .filter( ([, error]) => error instanceof HttpError && error.status === 404 ) - .map(([rawEventId]) => - fetchDrop(parseInt(rawEventId), /*includeDescription*/false) + .map(([rawDropId]) => + fetchDrop(parseInt(rawDropId), /*includeDescription*/false) ) ) - for (const eventResult of eventsNotFound) { - if (eventResult.status === 'rejected') { + for (const dropResult of dropsNotFound) { + if (dropResult.status === 'rejected') { continue } - const event = eventResult.value + const drop = dropResult.value - if (!event) { + if (!drop) { continue } - events[event.id] = event + drops[drop.id] = drop - if (event.id in errors) { - delete errorsByEventId[event.id] + if (drop.id in errors) { + delete errorsByDropId[drop.id] } } - if (Object.keys(errorsByEventId).length > 0) { + if (Object.keys(errorsByDropId).length > 0) { const response = JSON.stringify({ errorsByEventId: Object.fromEntries( - Object.entries(errorsByEventId).map( + Object.entries(errorsByDropId).map( ([eventId, error]) => ([ eventId, { @@ -189,8 +138,5 @@ export async function eventsLoader({ params, request }) { } } - return { - ...events, - ...freshEvents, - } + return drops } diff --git a/src/models/api.ts b/src/models/api.ts index c93cd6f..a52e9bd 100644 --- a/src/models/api.ts +++ b/src/models/api.ts @@ -1,4 +1,4 @@ -import { Drop, DropMetrics } from 'models/drop' +import { Drop } from 'models/drop' export const FAMILY_API_URL = process.env.REACT_APP_FAMILY_API_URL ?? 'https://api.poap.family' export const FAMILY_API_KEY = process.env.REACT_APP_FAMILY_API_KEY @@ -33,13 +33,6 @@ export interface EventsInCommon { ts: number | null } -export interface EventAndOwners { - event: Drop - owners: string[] - ts: number - metrics: DropMetrics | null -} - export interface CachedEvent { id: number name: string diff --git a/src/models/event.ts b/src/models/event.ts index 3c35e98..d25df20 100644 --- a/src/models/event.ts +++ b/src/models/event.ts @@ -1,6 +1,3 @@ -import { parseEndOfDayDate } from 'utils/date' -import { Drop } from 'models/drop' - export const SEARCH_LIMIT = 10 export const DEFAULT_DROP_LIMIT = 100 @@ -18,18 +15,3 @@ export function parseEventIds(rawIds: string): number[] { export function joinEventIds(eventIds: number[]): string { return parseEventIds(eventIds.join(',')).join(',') } - -export function parseExpiryDates(events: Record): Record { - return Object.fromEntries( - Object.entries(events) - .map( - ([eventId, event]) => ([ - eventId, - event?.expiry_date - ? parseEndOfDayDate(event.expiry_date) - : undefined, - ]) - ) - .filter(([, endOfDayDate]) => endOfDayDate != null) - ) -} diff --git a/src/pages/Events.tsx b/src/pages/Events.tsx index a82f54b..887e32b 100644 --- a/src/pages/Events.tsx +++ b/src/pages/Events.tsx @@ -4,7 +4,7 @@ import { formatStat } from 'utils/number' import { HTMLContext } from 'stores/html' import { ReverseEnsContext } from 'stores/ethereum' import { mergeAllInCommon } from 'models/in-common' -import { parseEventIds, parseExpiryDates } from 'models/event' +import { parseEventIds } from 'models/event' import { Drop, parseDrops } from 'models/drop' import { EnsByAddress } from 'models/ethereum' import { InCommon } from 'models/api' @@ -55,11 +55,6 @@ function Events() { [events] ) - const expiryDates = useMemo( - () => parseExpiryDates(events), - [events] - ) - const { completedEventsOwnersAndMetrics, loadingEventsOwnersAndMetrics, @@ -69,7 +64,7 @@ function Events() { eventsMetrics, fetchEventsOwnersAndMetrics, retryEventOwnersAndMetrics, - } = useEventsOwnersAndMetrics(eventIds, expiryDates, force) + } = useEventsOwnersAndMetrics(eventIds) const { completedEventsInCommon, diff --git a/src/utils/date.ts b/src/utils/date.ts index de302ae..a549c71 100644 --- a/src/utils/date.ts +++ b/src/utils/date.ts @@ -30,7 +30,3 @@ export function secondsInTheFuture(secs: number): string { export function formatMonthYear(date: Date | number | string): string { return dayjs(date).format('MMM \'YY') } - -export function parseEndOfDayDate(date: Date | number | string): Date { - return dayjs(date).endOf('day').toDate() -} From a7ae233775265156227f94a6ca4a9e1de93d2548 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:12:43 -0300 Subject: [PATCH 02/11] Type check --- package.json | 3 ++- tsconfig.json | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index aafb424..41811b4 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,8 @@ "main": "src/index.js", "scripts": { "start": "react-scripts start", - "build": "react-scripts build" + "build": "react-scripts build", + "type-check": "tsc --noEmit" }, "packageManager": "yarn@1.22.22", "engines": { diff --git a/tsconfig.json b/tsconfig.json index 9c28a3b..d46b79c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,7 +9,9 @@ "allowJs": true, "checkJs": true, "strict": false, - "jsx": "react-jsx" + "jsx": "react-jsx", + "skipLibCheck": true }, - "include": ["src"] + "include": ["src"], + "exclude": ["node_modules"] } From e268da140c8a750fef25b2c203fd16ebd75ed7f7 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:27:01 -0300 Subject: [PATCH 03/11] Remove drop cached ts --- src/components/EventStats.tsx | 4 - src/loaders/event.ts | 16 +-- src/models/drop.ts | 193 +++++++++++++--------------------- src/pages/Event.tsx | 49 ++++----- 4 files changed, 106 insertions(+), 156 deletions(-) diff --git a/src/components/EventStats.tsx b/src/components/EventStats.tsx index 62752a7..53cdb0a 100644 --- a/src/components/EventStats.tsx +++ b/src/components/EventStats.tsx @@ -7,12 +7,10 @@ import Stats from 'components/Stats' function EventStats({ event, collectors, - cachedTs, metrics, }: { event: Drop collectors: number - cachedTs?: number metrics?: DropMetrics }) { const stats = { @@ -22,14 +20,12 @@ function EventStats({ } : { text: formatStat(collectors), - title: cachedTs != null ? `Cached ${formatDateAgo(cachedTs)}` : undefined, }, } if (metrics && metrics.emailReservations > 0) { stats['mints'] = { text: formatStat(collectors), - title: cachedTs != null ? `Cached ${formatDateAgo(cachedTs)}` : undefined, } stats['reservations'] = { text: formatStat(metrics.emailReservations), diff --git a/src/loaders/event.ts b/src/loaders/event.ts index 4d0d2c4..cc3935b 100644 --- a/src/loaders/event.ts +++ b/src/loaders/event.ts @@ -1,9 +1,10 @@ import { parseEventIds } from 'models/event' +import { Drop, DropData } from 'models/drop' import { HttpError } from 'models/error' import { fetchDrop, fetchDropMetrics, fetchDropsOrErrors } from 'loaders/drop' import { fetchDropsCollectors } from 'loaders/collector' -export async function eventLoader({ params }) { +export async function eventLoader({ params }): Promise { const dropId = parseInt(String(params.eventId)) if (isNaN(dropId)) { @@ -13,9 +14,9 @@ export async function eventLoader({ params }) { }) } - const event = await fetchDrop(dropId, /*includeDescription*/true) + const drop = await fetchDrop(dropId, /*includeDescription*/true) - if (!event) { + if (!drop) { throw new Response('', { status: 404, statusText: 'Drop not found', @@ -35,20 +36,19 @@ export async function eventLoader({ params }) { }) } - const owners = collectorsSettled.value + const collectors = collectorsSettled.value const metrics = metricsSettled.status === 'fulfilled' ? metricsSettled.value : null return { - event, - owners, - ts: null, + drop, + collectors, metrics, } } -export async function eventsLoader({ params }) { +export async function eventsLoader({ params }): Promise> { const eventIds = parseEventIds(params.eventIds) if (eventIds.length === 0) { diff --git a/src/models/drop.ts b/src/models/drop.ts index d8c3667..9d0e91d 100644 --- a/src/models/drop.ts +++ b/src/models/drop.ts @@ -11,68 +11,68 @@ export interface Drop { expiry_date: string } -export function parseDrop(event: unknown, includeDescription: boolean): Drop { +export function parseDrop(data: unknown, includeDescription: boolean): Drop { if ( - event == null || - typeof event !== 'object' || - !('id' in event) || - event.id == null || - typeof event.id !== 'number' || - !('name' in event) || - event.name == null || - typeof event.name !== 'string' || + data == null || + typeof data !== 'object' || + !('id' in data) || + data.id == null || + typeof data.id !== 'number' || + !('name' in data) || + data.name == null || + typeof data.name !== 'string' || ( includeDescription && ( - !('description' in event) || - event.description == null || - typeof event.description !== 'string' + !('description' in data) || + data.description == null || + typeof data.description !== 'string' ) ) || - !('image_url' in event) || - event.image_url == null || - typeof event.image_url !== 'string' || - !('city' in event) || - (event.city != null && typeof event.city !== 'string') || - !('country' in event) || - (event.country != null && typeof event.country !== 'string') || - !('start_date' in event) || - event.start_date == null || - typeof event.start_date !== 'string' || - !('end_date' in event) || - event.end_date == null || - typeof event.end_date !== 'string' || - !('expiry_date' in event) || - event.expiry_date == null || - typeof event.expiry_date !== 'string' + !('image_url' in data) || + data.image_url == null || + typeof data.image_url !== 'string' || + !('city' in data) || + (data.city != null && typeof data.city !== 'string') || + !('country' in data) || + (data.country != null && typeof data.country !== 'string') || + !('start_date' in data) || + data.start_date == null || + typeof data.start_date !== 'string' || + !('end_date' in data) || + data.end_date == null || + typeof data.end_date !== 'string' || + !('expiry_date' in data) || + data.expiry_date == null || + typeof data.expiry_date !== 'string' ) { - throw new Error('Invalid drop') + throw new Error('Malformed drop') } return { - id: event.id, - name: event.name, + id: data.id, + name: data.name, description: includeDescription ? ( - 'description' in event && - event.description != null && - typeof event.description === 'string' - ? event.description + 'description' in data && + data.description != null && + typeof data.description === 'string' + ? data.description : '' ) : undefined, - image_url: event.image_url, + image_url: data.image_url, original_url: ( - 'original_url' in event && - typeof event.original_url !== 'string' - ? event.original_url + 'original_url' in data && + typeof data.original_url !== 'string' + ? data.original_url : ( - 'drop_image' in event && - event.drop_image != null && - typeof event.drop_image === 'object' && - 'gateways' in event.drop_image && - event.drop_image.gateways != null && - Array.isArray(event.drop_image.gateways) - ? event.drop_image?.gateways?.reduce( + 'drop_image' in data && + data.drop_image != null && + typeof data.drop_image === 'object' && + 'gateways' in data.drop_image && + data.drop_image.gateways != null && + Array.isArray(data.drop_image.gateways) + ? data.drop_image?.gateways?.reduce( (original, gateway) => ( gateway != null && typeof gateway === 'object' && @@ -86,43 +86,16 @@ export function parseDrop(event: unknown, includeDescription: boolean): Drop { ? gateway.url : original ), - event.image_url + data.image_url ) - : event.image_url + : data.image_url ) ), - city: typeof event.city === 'string' ? event.city : null, - country: typeof event.country === 'string' ? event.country : null, - start_date: event.start_date, - end_date: event.end_date, - expiry_date: event.expiry_date, - } -} - -export interface DropOwners { - owners: string[] - ts: number -} - -export function parseDropOwners(eventOwners: unknown): DropOwners { - if ( - eventOwners == null || - typeof eventOwners !== 'object' || - !('owners' in eventOwners) || - !Array.isArray(eventOwners.owners) || - !eventOwners.owners.every((owner) => - owner != null && - typeof owner === 'string' - ) || - !('ts' in eventOwners) || - eventOwners.ts == null || - typeof eventOwners.ts !== 'number' - ) { - throw new Error('Malformed drop owners') - } - return { - owners: eventOwners.owners, - ts: eventOwners.ts, + city: typeof data.city === 'string' ? data.city : null, + country: typeof data.country === 'string' ? data.country : null, + start_date: data.start_date, + end_date: data.end_date, + expiry_date: data.expiry_date, } } @@ -228,61 +201,47 @@ export function parseDropMetrics(eventMetrics: unknown): DropMetrics | null { throw new Error('Malformed drop metrics') } +export interface DropData { + drop: Drop + collectors: string[] + metrics: DropMetrics | null +} + export function parseDropData( data: unknown, includeDescription: boolean = false, includeMetrics: boolean = true, -): { - event: Drop - owners: string[] - ts: number | null - metrics: DropMetrics | null -} { +): DropData { if ( data == null || typeof data !== 'object' || !('event' in data) || - !('owners' in data) || - !('ts' in data) + !('owners' in data) ) { - throw new Error('Malformed drop data') + throw new Error('Malformed drop data: missing drop or collectors') } - let dropOwners: DropOwners - if (data.ts == null) { - if ( - !Array.isArray(data.owners) || - !data.owners.every((owner) => - owner != null && - typeof owner === 'string' - ) - ) { - throw new Error('Malformed owners') - } - dropOwners = { - owners: data.owners, - ts: null, - } - } else { - dropOwners = parseDropOwners({ - owners: data.owners, - ts: data.ts, - }) + if ( + !Array.isArray(data.owners) || + !data.owners.every((owner) => + owner != null && + typeof owner === 'string' + ) + ) { + throw new Error('Malformed drop data: malformed collectors') } if (!includeMetrics) { return { - event: parseDrop(data.event, includeDescription), - owners: dropOwners.owners, - ts: dropOwners.ts, + drop: parseDrop(data.event, includeDescription), + collectors: data.owners, metrics: null, } } if (!('metrics' in data)) { - throw new Error('Malformed drop data') + throw new Error('Malformed drop data: missing metrics') } return { - event: parseDrop(data.event, includeDescription), - owners: dropOwners.owners, - ts: dropOwners.ts, + drop: parseDrop(data.event, includeDescription), + collectors: data.owners, metrics: parseDropMetrics(data.metrics), } } @@ -297,7 +256,7 @@ export function parseDrops( return Object.fromEntries( Object.entries(drops).map( - ([eventId, event]) => [eventId, parseDrop(event, includeDescription)] + ([rawDropId, drop]) => [rawDropId, parseDrop(drop, includeDescription)] ) ) } diff --git a/src/pages/Event.tsx b/src/pages/Event.tsx index 0aba8aa..0f2fabf 100644 --- a/src/pages/Event.tsx +++ b/src/pages/Event.tsx @@ -32,7 +32,7 @@ function Event() { const force = searchParams.get('force') === 'true' - const { event, owners, ts, metrics } = useMemo( + const { drop, collectors, metrics } = useMemo( () => parseDropData( loaderData, /*includeDescription*/true, @@ -55,16 +55,16 @@ function Event() { fetchEventInCommon, retryAddress, } = useEventInCommon( - event.id, - owners, + drop.id, + collectors, /*refresh*/force, /*local*/false, /*stream*/true ) const eventIds = useMemo( - () => [event.id], - [event] + () => [drop.id], + [drop] ) const { @@ -78,9 +78,9 @@ function Event() { useEffect( () => { - resolveEnsNames(owners) + resolveEnsNames(collectors) }, - [owners, resolveEnsNames] + [collectors, resolveEnsNames] ) useEffect( @@ -95,9 +95,9 @@ function Event() { useEffect( () => { - setTitle(event.name) + setTitle(drop.name) }, - [event.name, setTitle] + [drop.name, setTitle] ) useEffect( @@ -143,23 +143,22 @@ function Event() {
- + - + - + {cachedTs &&
@@ -178,7 +177,7 @@ function Event() { {loadingEventInCommon && ( {loadedOwners > 0 - ? + ? : ( loadedInCommonEvents != null ? ( @@ -217,12 +216,8 @@ function Event() { <> {( cachedTs && - ( - !ts || - ts > cachedTs - ) && - event.id in inCommon && - inCommon[event.id].length !== owners.length + drop.id in inCommon && + inCommon[drop.id].length !== collectors.length ) && ( There have been new mints since this POAP was cached,{' '} @@ -256,7 +251,7 @@ function Event() { ) && ( 0} - emptyMessage={`No collections found that includes ${event.name}`} + emptyMessage={`No collections found that includes ${drop.name}`} collectionMap={{ [`${collections.length} collections`]: collections, }} From ebc73f8e1da073eddff7960ba597674d1798424d Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:28:44 -0300 Subject: [PATCH 04/11] Rename events by drops --- src/loaders/event.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/loaders/event.ts b/src/loaders/event.ts index cc3935b..899e80f 100644 --- a/src/loaders/event.ts +++ b/src/loaders/event.ts @@ -49,37 +49,37 @@ export async function eventLoader({ params }): Promise { } export async function eventsLoader({ params }): Promise> { - const eventIds = parseEventIds(params.eventIds) + const dropIds = parseEventIds(params.eventIds) - if (eventIds.length === 0) { + if (dropIds.length === 0) { throw new Response('', { status: 404, statusText: 'Drops not found', }) } - if (params.eventIds !== eventIds.join(',')) { + if (params.eventIds !== dropIds.join(',')) { throw new Response('', { status: 301, statusText: 'Drops given unordered', headers: { - location: `/events/${eventIds.join(',')}`, + location: `/events/${dropIds.join(',')}`, }, }) } - if (eventIds.length === 1) { + if (dropIds.length === 1) { throw new Response('', { status: 301, statusText: 'One drop', headers: { - location: `/event/${eventIds[0]}`, + location: `/event/${dropIds[0]}`, }, }) } const [drops, errors] = await fetchDropsOrErrors( - eventIds, + dropIds, /*includeDescription*/false ) From 3d49a53f792ea5e33078857f16f2d982a2406fd1 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:32:39 -0300 Subject: [PATCH 05/11] Remove metrics cached ts --- src/components/EventStats.tsx | 10 ++++------ src/loaders/drop.ts | 1 - src/models/drop.ts | 33 --------------------------------- src/pages/Event.tsx | 8 +------- 4 files changed, 5 insertions(+), 47 deletions(-) diff --git a/src/components/EventStats.tsx b/src/components/EventStats.tsx index 53cdb0a..e100f21 100644 --- a/src/components/EventStats.tsx +++ b/src/components/EventStats.tsx @@ -1,15 +1,14 @@ import { Drop, DropMetrics } from 'models/drop' import { POAP_MOMENTS_URL } from 'models/poap' import { formatStat } from 'utils/number' -import { formatDateAgo } from 'utils/date' import Stats from 'components/Stats' function EventStats({ - event, + drop, collectors, metrics, }: { - event: Drop + drop: Drop collectors: number metrics?: DropMetrics }) { @@ -29,7 +28,6 @@ function EventStats({ } stats['reservations'] = { text: formatStat(metrics.emailReservations), - title: metrics.ts ? `Cached ${formatDateAgo(metrics.ts)}` : undefined, } } @@ -49,8 +47,8 @@ function EventStats({ if (metrics && metrics.momentsUploaded > 0) { stats['moments'] = { text: formatStat(metrics.momentsUploaded), - title: `View uploaded moments on ${event.name}`, - href: `${POAP_MOMENTS_URL}/drop/${event.id}`, + title: `View uploaded moments on ${drop.name}`, + href: `${POAP_MOMENTS_URL}/drop/${drop.id}`, external: true, } } diff --git a/src/loaders/drop.ts b/src/loaders/drop.ts index ea6f28f..cf28e00 100644 --- a/src/loaders/drop.ts +++ b/src/loaders/drop.ts @@ -304,7 +304,6 @@ export async function fetchDropsMetrics( emailClaims: drop.emailClaims, momentsUploaded: drop.momentsUploaded, collectionsIncludes: drop.collectionsIncludes, - ts: drop.ts, } } } diff --git a/src/models/drop.ts b/src/models/drop.ts index 9d0e91d..3b8e05f 100644 --- a/src/models/drop.ts +++ b/src/models/drop.ts @@ -105,44 +105,12 @@ export interface DropMetrics { emailClaims: number momentsUploaded: number collectionsIncludes: number - ts: number | null } export function parseDropMetrics(eventMetrics: unknown): DropMetrics | null { if (eventMetrics == null) { return null } - if ( - typeof eventMetrics === 'object' && - eventMetrics != null && - 'emailReservations' in eventMetrics && - eventMetrics.emailReservations != null && - typeof eventMetrics.emailReservations === 'number' && - 'emailClaimsMinted' in eventMetrics && - eventMetrics.emailClaimsMinted != null && - typeof eventMetrics.emailClaimsMinted === 'number' && - 'emailClaims' in eventMetrics && - eventMetrics.emailClaims != null && - typeof eventMetrics.emailClaims === 'number' && - 'momentsUploaded' in eventMetrics && - eventMetrics.momentsUploaded != null && - typeof eventMetrics.momentsUploaded === 'number' && - 'collectionsIncludes' in eventMetrics && - eventMetrics.collectionsIncludes != null && - typeof eventMetrics.collectionsIncludes === 'number' && - 'ts' in eventMetrics && - eventMetrics.ts != null && - typeof eventMetrics.ts === 'number' - ) { - return { - emailReservations: eventMetrics.emailReservations, - emailClaimsMinted: eventMetrics.emailClaimsMinted, - emailClaims: eventMetrics.emailClaims, - momentsUploaded: eventMetrics.momentsUploaded, - collectionsIncludes: eventMetrics.collectionsIncludes, - ts: eventMetrics.ts, - } - } if ( typeof eventMetrics === 'object' && eventMetrics != null && @@ -195,7 +163,6 @@ export function parseDropMetrics(eventMetrics: unknown): DropMetrics | null { momentsUploaded, collectionsIncludes: eventMetrics.collections_items_aggregate.aggregate.count, - ts: null, } } throw new Error('Malformed drop metrics') diff --git a/src/pages/Event.tsx b/src/pages/Event.tsx index 0f2fabf..2d2c010 100644 --- a/src/pages/Event.tsx +++ b/src/pages/Event.tsx @@ -145,7 +145,7 @@ function Event() {
@@ -166,12 +166,6 @@ function Event() { refreshCache()}>refresh.
} - {!cachedTs && metrics && metrics.ts && -
- Cached ,{' '} - refreshCache()}>refresh. -
- }
{loadingEventInCommon && ( From 4cafbd78a3dbbea3e7240409fc97e1e3d662b933 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:37:54 -0300 Subject: [PATCH 06/11] Fix parse drop data --- src/models/drop.ts | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/models/drop.ts b/src/models/drop.ts index 3b8e05f..0ff2d3b 100644 --- a/src/models/drop.ts +++ b/src/models/drop.ts @@ -182,24 +182,26 @@ export function parseDropData( if ( data == null || typeof data !== 'object' || - !('event' in data) || - !('owners' in data) + !('drop' in data) || + !('collectors' in data) ) { throw new Error('Malformed drop data: missing drop or collectors') } if ( - !Array.isArray(data.owners) || - !data.owners.every((owner) => - owner != null && - typeof owner === 'string' + !Array.isArray(data.collectors) || + !data.collectors.every((collector: unknown): collector is string => + collector != null && + typeof collector === 'string' && + collector.startsWith('0x') && + collector.length === 42 ) ) { throw new Error('Malformed drop data: malformed collectors') } if (!includeMetrics) { return { - drop: parseDrop(data.event, includeDescription), - collectors: data.owners, + drop: parseDrop(data.drop, includeDescription), + collectors: data.collectors, metrics: null, } } @@ -207,8 +209,8 @@ export function parseDropData( throw new Error('Malformed drop data: missing metrics') } return { - drop: parseDrop(data.event, includeDescription), - collectors: data.owners, + drop: parseDrop(data.drop, includeDescription), + collectors: data.collectors, metrics: parseDropMetrics(data.metrics), } } From 30f9badb77d57573eda8cba6f23c600c386cabe7 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:39:07 -0300 Subject: [PATCH 07/11] Restore parse drop metrics without ts --- src/models/drop.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/models/drop.ts b/src/models/drop.ts index 0ff2d3b..a9eb7aa 100644 --- a/src/models/drop.ts +++ b/src/models/drop.ts @@ -111,6 +111,33 @@ export function parseDropMetrics(eventMetrics: unknown): DropMetrics | null { if (eventMetrics == null) { return null } + if ( + typeof eventMetrics === 'object' && + eventMetrics != null && + 'emailReservations' in eventMetrics && + eventMetrics.emailReservations != null && + typeof eventMetrics.emailReservations === 'number' && + 'emailClaimsMinted' in eventMetrics && + eventMetrics.emailClaimsMinted != null && + typeof eventMetrics.emailClaimsMinted === 'number' && + 'emailClaims' in eventMetrics && + eventMetrics.emailClaims != null && + typeof eventMetrics.emailClaims === 'number' && + 'momentsUploaded' in eventMetrics && + eventMetrics.momentsUploaded != null && + typeof eventMetrics.momentsUploaded === 'number' && + 'collectionsIncludes' in eventMetrics && + eventMetrics.collectionsIncludes != null && + typeof eventMetrics.collectionsIncludes === 'number' + ) { + return { + emailReservations: eventMetrics.emailReservations, + emailClaimsMinted: eventMetrics.emailClaimsMinted, + emailClaims: eventMetrics.emailClaims, + momentsUploaded: eventMetrics.momentsUploaded, + collectionsIncludes: eventMetrics.collectionsIncludes, + } + } if ( typeof eventMetrics === 'object' && eventMetrics != null && From 8cedc0d0c8bbc35077d7e7e98b39d3c2b5cde7fc Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 13:40:51 -0300 Subject: [PATCH 08/11] CS --- src/pages/Events.tsx | 142 +++++++++++++++++++++---------------------- 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/src/pages/Events.tsx b/src/pages/Events.tsx index 887e32b..70b3252 100644 --- a/src/pages/Events.tsx +++ b/src/pages/Events.tsx @@ -45,14 +45,14 @@ function Events() { const force = searchParams.get('force') === 'true' const all = searchParams.get('all') === 'true' - const events = useMemo( + const drops = useMemo( () => parseDrops(loaderData, /*includeDescription*/false), [loaderData] ) const eventIds = useMemo( - () => Object.keys(events).map((rawEventId) => parseInt(rawEventId)), - [events] + () => Object.keys(drops).map((rawEventId) => parseInt(rawEventId)), + [drops] ) const { @@ -97,9 +97,9 @@ function Events() { useEffect( () => { - setTitle(Object.values(events).map((event) => event.name).join(', ')) + setTitle(Object.values(drops).map((event) => event.name).join(', ')) }, - [events, setTitle] + [drops, setTitle] ) useEffect( @@ -286,30 +286,30 @@ function Events() { - {Object.values(events).map((event) => ( - + {Object.values(drops).map((drop) => ( +
- #{event.id} + #{drop.id}
-

{event.name}

+

{drop.name}

- {formatDate(event.start_date)} + {formatDate(drop.start_date)}
- {event.city && event.country && ( + {drop.city && drop.country && (
- {event.city}, {event.country} + {drop.city}, {drop.country}
)}
@@ -317,18 +317,18 @@ function Events() { {( loadingEventsOwnersAndMetrics || - loadingOwnersAndMetricsEvents[event.id] != null + loadingOwnersAndMetricsEvents[drop.id] != null ) && ( )} - {eventsOwners[event.id] != null && ( + {eventsOwners[drop.id] != null && ( - {formatStat(eventsOwners[event.id].length)} + {formatStat(eventsOwners[drop.id].length)} {( - eventsMetrics[event.id] != null && - eventsMetrics[event.id].emailReservations > 0 + eventsMetrics[drop.id] != null && + eventsMetrics[drop.id].emailReservations > 0 ) && ( - ` + ${formatStat(eventsMetrics[event.id].emailReservations)}` + ` + ${formatStat(eventsMetrics[drop.id].emailReservations)}` )} )} @@ -336,26 +336,26 @@ function Events() { - {eventsOwnersAndMetricsErrors[event.id] != null && ( + {eventsOwnersAndMetricsErrors[drop.id] != null && ( <> - {eventsOwnersAndMetricsErrors[event.id].message} + {eventsOwnersAndMetricsErrors[drop.id].message} {' '} retryEventOwnersAndMetrics(event.id)} + onClick={() => retryEventOwnersAndMetrics(drop.id)} > retry @@ -364,57 +364,57 @@ function Events() { {( - loadingInCommonEvents[event.id] != null && - loadedEventsInCommon[event.id] == null && - loadedEventsInCommonEvents[event.id] == null && - loadedEventsProgress[event.id] == null && - loadedEventsOwners[event.id] != null && - eventsOwners[event.id] != null + loadingInCommonEvents[drop.id] != null && + loadedEventsInCommon[drop.id] == null && + loadedEventsInCommonEvents[drop.id] == null && + loadedEventsProgress[drop.id] == null && + loadedEventsOwners[drop.id] != null && + eventsOwners[drop.id] != null ) && ( 0} + value={loadedEventsOwners[drop.id]} + max={eventsOwners[drop.id].length} + showValue={loadedEventsOwners[drop.id] > 0} /> )} {( - loadedEventsInCommon[event.id] != null && - loadedEventsInCommonEvents[event.id] == null && - loadedEventsProgress[event.id] == null + loadedEventsInCommon[drop.id] != null && + loadedEventsInCommonEvents[drop.id] == null && + loadedEventsProgress[drop.id] == null ) && ( 0} + value={loadedEventsInCommon[drop.id].count} + max={loadedEventsInCommon[drop.id].total} + maxFinal={loadedEventsInCommon[drop.id].totalFinal} + showValue={loadedEventsInCommon[drop.id].total > 0} /> )} {( - loadedEventsInCommon[event.id] != null && - loadedEventsInCommonEvents[event.id] != null && - loadedEventsProgress[event.id] == null + loadedEventsInCommon[drop.id] != null && + loadedEventsInCommonEvents[drop.id] != null && + loadedEventsProgress[drop.id] == null ) && ( 0} + value={loadedEventsInCommonEvents[drop.id].count} + max={loadedEventsInCommonEvents[drop.id].total} + showValue={loadedEventsInCommonEvents[drop.id].total > 0} /> )} {( - loadedEventsInCommon[event.id] == null && - loadedEventsInCommonEvents[event.id] == null && - loadedEventsProgress[event.id] != null + loadedEventsInCommon[drop.id] == null && + loadedEventsInCommonEvents[drop.id] == null && + loadedEventsProgress[drop.id] != null ) && ( )} - {eventsInCommonErrors[event.id] != null && Object.entries( - eventsInCommonErrors[event.id] + {eventsInCommonErrors[drop.id] != null && Object.entries( + eventsInCommonErrors[drop.id] ).map( ([address, error]) => (

@@ -426,7 +426,7 @@ function Events() { {' '} { - retryEventAddressInCommon(event.id, address) + retryEventAddressInCommon(drop.id, address) }} > retry @@ -435,17 +435,17 @@ function Events() { ) )} {( - eventsInCommon[event.id] != null && - eventsInCommon[event.id].ts != null + eventsInCommon[drop.id] != null && + eventsInCommon[drop.id].ts != null ) && (

- Cached + Cached {( - completedInCommonEvents[event.id] && - eventsOwners[event.id] != null && - eventsInCommon[event.id] != null && - eventsInCommon[event.id].inCommon[event.id] != null && - eventsInCommon[event.id].inCommon[event.id].length !== eventsOwners[event.id].length + completedInCommonEvents[drop.id] && + eventsOwners[drop.id] != null && + eventsInCommon[drop.id] != null && + eventsInCommon[drop.id].inCommon[drop.id] != null && + eventsInCommon[drop.id].inCommon[drop.id].length !== eventsOwners[drop.id].length ) && ( <> {' '} @@ -459,13 +459,13 @@ function Events() { delEvent(event.id)} - title={`Removes drop #${event.id}`} + onDelete={() => delEvent(drop.id)} + title={`Removes drop #${drop.id}`} /> @@ -521,7 +521,7 @@ function Events() { emptyMessage={( <> No collections found that includes exactly all{' '} - {Object.keys(events).length} POAPs,{' '} + {Object.keys(drops).length} POAPs,{' '} view related collections . From f6188fce91e5a5ed720f9764986072791ea877c5 Mon Sep 17 00:00:00 2001 From: Juan Date: Thu, 19 Dec 2024 14:10:50 -0300 Subject: [PATCH 09/11] CS --- src/components/EventInfo.tsx | 18 +++++++++--------- src/pages/Event.tsx | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/components/EventInfo.tsx b/src/components/EventInfo.tsx index 0997c5e..2e644bf 100644 --- a/src/components/EventInfo.tsx +++ b/src/components/EventInfo.tsx @@ -11,22 +11,22 @@ import ExternalLink from 'components/ExternalLink' import 'styles/event-info.css' function EventInfo({ - event, + drop, children, }: { - event: Drop + drop: Drop children?: ReactNode }) { const [extraOpen, setExtraOpen] = useState(false) return (

- {event.description && ( + {drop.description && (
{extraOpen && (
- {event.description.split('\n').map( + {drop.description.split('\n').map( (p, i) => (

{linkify(p, ExternalLink).map( @@ -54,13 +54,13 @@ function EventInfo({ >

- +
-

{event.name}

-
{formatDate(event.start_date)}
- {event.city && event.country && ( -
{event.city}, {event.country}
+

{drop.name}

+
{formatDate(drop.start_date)}
+ {drop.city && drop.country && ( +
{drop.city}, {drop.country}
)} {children}
diff --git a/src/pages/Event.tsx b/src/pages/Event.tsx index 2d2c010..d8ef456 100644 --- a/src/pages/Event.tsx +++ b/src/pages/Event.tsx @@ -143,7 +143,7 @@ function Event() {
- + Date: Thu, 19 Dec 2024 14:12:16 -0300 Subject: [PATCH 10/11] CS --- src/components/AddressOwner.tsx | 2 +- src/components/AddressProfile.tsx | 4 ++-- src/components/CachedEventList.tsx | 2 +- src/components/EventHeader.tsx | 2 +- src/components/EventInfo.tsx | 2 +- src/components/EventPower.tsx | 2 +- src/components/EventsPowers.tsx | 2 +- src/components/SearchResultEvent.tsx | 2 +- src/components/TokenImage.tsx | 14 +++++++------- src/components/TokenImageZoom.tsx | 18 +++++++++--------- src/pages/Addresses.tsx | 2 +- src/pages/Events.tsx | 2 +- 12 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/components/AddressOwner.tsx b/src/components/AddressOwner.tsx index a7fbace..2715cc5 100644 --- a/src/components/AddressOwner.tsx +++ b/src/components/AddressOwner.tsx @@ -62,7 +62,7 @@ function AddressOwner({ ? ( diff --git a/src/components/AddressProfile.tsx b/src/components/AddressProfile.tsx index 468ae3d..200f2de 100644 --- a/src/components/AddressProfile.tsx +++ b/src/components/AddressProfile.tsx @@ -127,7 +127,7 @@ function AddressProfile({ token.id && token.event && ( @@ -159,7 +159,7 @@ function AddressProfile({ eventId in events && ( diff --git a/src/components/CachedEventList.tsx b/src/components/CachedEventList.tsx index 1921e6c..61ee061 100644 --- a/src/components/CachedEventList.tsx +++ b/src/components/CachedEventList.tsx @@ -42,7 +42,7 @@ function CachedEventList({
diff --git a/src/components/EventHeader.tsx b/src/components/EventHeader.tsx index f7c62c2..7294278 100644 --- a/src/components/EventHeader.tsx +++ b/src/components/EventHeader.tsx @@ -13,7 +13,7 @@ function EventHeader({ return (
- +
#{event.id} diff --git a/src/components/EventInfo.tsx b/src/components/EventInfo.tsx index 2e644bf..f643be2 100644 --- a/src/components/EventInfo.tsx +++ b/src/components/EventInfo.tsx @@ -54,7 +54,7 @@ function EventInfo({ >
- +

{drop.name}

diff --git a/src/components/EventPower.tsx b/src/components/EventPower.tsx index 4ac6f96..4cca2e3 100644 --- a/src/components/EventPower.tsx +++ b/src/components/EventPower.tsx @@ -13,7 +13,7 @@ function EventPower({ }) { return (
- + {count}
) diff --git a/src/components/EventsPowers.tsx b/src/components/EventsPowers.tsx index 75b5cde..803c404 100644 --- a/src/components/EventsPowers.tsx +++ b/src/components/EventsPowers.tsx @@ -48,7 +48,7 @@ function EventsPowers({ }} > {perfectPower === power - ? + ? :
- +
diff --git a/src/components/TokenImage.tsx b/src/components/TokenImage.tsx index 5dee344..0559ca6 100644 --- a/src/components/TokenImage.tsx +++ b/src/components/TokenImage.tsx @@ -4,23 +4,23 @@ import { resizeTokenImageUrl } from 'models/poap' import 'styles/token-image.css' function TokenImage({ - event, + drop, size, imgSize, resize = true, imgix = false, original = false, }: { - event: Drop | CachedEvent + drop: Drop | CachedEvent size: number imgSize?: number resize?: boolean imgix?: boolean original?: boolean }) { - let imageUrl = original && 'original_url' in event - ? event.original_url ?? event.image_url - : event.image_url + let imageUrl = original && 'original_url' in drop + ? drop.original_url ?? drop.image_url + : drop.image_url if (resize) { imageUrl = resizeTokenImageUrl(imageUrl, size, imgix) @@ -29,8 +29,8 @@ function TokenImage({ return ( {event.name} setShowModal((show) => !show)} className="token-image-zoom-in-button" > - + setShowModal(false)} - title={event.name} + title={drop.name} > (
@@ -42,7 +42,7 @@ function TokenImageZoom({ event, size = 128, zoomSize = 512 }: { className="token-image-zoom-out-button" > + ) } diff --git a/src/pages/Events.tsx b/src/pages/Events.tsx index 70b3252..022228c 100644 --- a/src/pages/Events.tsx +++ b/src/pages/Events.tsx @@ -291,7 +291,7 @@ function Events() {
From 754a8c24fee89ffac5abbd7f5cd3b6b7a70c2990 Mon Sep 17 00:00:00 2001 From: Juan Date: Fri, 20 Dec 2024 11:31:09 -0300 Subject: [PATCH 11/11] Version 1.22.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 41811b4..cde5e9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@poap-xyz/poap-family", - "version": "1.21.0", + "version": "1.22.0", "author": { "name": "POAP", "url": "https://poap.xyz"