Skip to content

Commit

Permalink
Merge pull request #422 from poap-xyz/relase/v1.18.0
Browse files Browse the repository at this point in the history
Release v1.18.0
  • Loading branch information
jm42 authored Dec 9, 2024
2 parents 6b85cd0 + b013352 commit 56b72d5
Show file tree
Hide file tree
Showing 14 changed files with 166 additions and 344 deletions.
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poap-xyz/poap-family",
"version": "1.17.3",
"version": "1.18.0",
"author": {
"name": "POAP",
"url": "https://poap.xyz"
Expand All @@ -19,26 +19,26 @@
"@ethersproject/contracts": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@mapbox/to-color": "^2.1.1",
"axios": "^1.7.2",
"axios": "^1.7.9",
"clsx": "^2.1.1",
"dayjs": "^1.11.11",
"dayjs": "^1.11.13",
"downloadjs": "^1.4.7",
"iconoir-react": "^7.7.0",
"iconoir-react": "^7.10.1",
"numbro": "^2.5.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-lazy-images": "^1.1.0",
"react-modal": "^3.16.1",
"react-router-dom": "^6.25.1",
"react-router-dom": "^6.28.0",
"react-scripts": "^5.0.1"
},
"devDependencies": {
"@types/downloadjs": "^1.4.6",
"@types/node": "^20.14.11",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/node": "^20.17.9",
"@types/react": "^18.3.14",
"@types/react-dom": "^18.3.2",
"@types/react-modal": "^3.16.3",
"typescript": "^5.5.3"
"typescript": "^5.7.2"
},
"main": "src/index.js",
"scripts": {
Expand Down
5 changes: 0 additions & 5 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import Addresses from 'pages/Addresses'
import Event from 'pages/Event'
import Events from 'pages/Events'
import Last from 'pages/Last'
import Settings from 'pages/Settings'
import FeedbackList from 'pages/FeedbackList'
import EventsPageError from 'components/EventsPageError'
import PageError from 'components/PageError'
Expand Down Expand Up @@ -58,10 +57,6 @@ export default function App() {
path: '/last',
element: <Last />,
},
{
path: '/settings',
element: <Settings />,
},
{
element: <Admin />,
children: [
Expand Down
26 changes: 9 additions & 17 deletions src/components/AddressOwner.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useSettings } from 'stores/settings'
import { Drop } from 'models/drop'
import TokenImage from 'components/TokenImage'
import LinkToScan from 'components/LinkToScan'
Expand All @@ -24,8 +23,6 @@ function AddressOwner({
inCommonAddresses?: string[]
linkToScan?: boolean
}) {
const { settings } = useSettings()

const hasEvents = (
events != null &&
typeof events === 'object' &&
Expand All @@ -37,21 +34,16 @@ function AddressOwner({
return (
<div className="address-owner">
<div className="owner-name">
{settings.openProfiles
? (
<ButtonAddressProfile
address={address}
events={events}
inCommonEventIds={inCommonEventIds}
inCommonAddresses={inCommonAddresses}
showEns={true}
ens={ens}
/>
)
: <LinkToScan address={address} showEns={true} ens={ens} />
}
<ButtonAddressProfile
address={address}
events={events}
inCommonEventIds={inCommonEventIds}
inCommonAddresses={inCommonAddresses}
showEns={true}
ens={ens}
/>
</div>
{linkToScan && settings.openProfiles && (
{linkToScan && (
<LinkToScan
address={address}
className="owner-scan"
Expand Down
6 changes: 3 additions & 3 deletions src/components/CollectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ function CollectionList({
}) {
const [showAll, setShowAll] = useState<boolean>(false)

let showCollections = collections.slice()
let collectionsToShow = collections.slice()

const total = collections.length
const limit = COLLECTIONS_LIMIT
const hasMore = total > limit

if (hasMore && !showAll) {
showCollections = showCollections.slice(0, limit)
collectionsToShow = collectionsToShow.slice(0, limit)
}

return (
<div className="collection-list">
{showCollections.map((collection) => (
{collectionsToShow.map((collection) => (
<a
key={collection.id}
title={collection.title}
Expand Down
57 changes: 1 addition & 56 deletions src/components/EventsCompare.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createRef, useEffect, useMemo, useState } from 'react'
import { useSettings } from 'stores/settings'
import { useMemo, useState } from 'react'
import { Drop } from 'models/drop'
import { InCommon } from 'models/api'
import {
Expand Down Expand Up @@ -32,9 +31,7 @@ function EventsCompare({
onClose: (eventId: number) => void
eventsEnsNames?: Record<number, EnsByAddress>
}) {
const { settings } = useSettings()
const [highlighted, setHighlighted] = useState<string | null>(null)
const [liRefs, setLiRefs] = useState<Record<number, Record<string, ReturnType<typeof createRef<HTMLLIElement>>>>>({})

const adressesColors = useMemo(
() => eventIds.length < 2
Expand All @@ -53,54 +50,7 @@ function EventsCompare({
[eventIds, inCommon]
)

useEffect(
() => {
if (eventIds.length > 0) {
const refs: Record<number, Record<string, ReturnType<typeof createRef<HTMLLIElement>>>> = {}
for (const eventId of eventIds) {
if (inCommon[eventId].length > 0) {
refs[eventId] = {}
for (const owner of inCommon[eventId]) {
refs[eventId][owner] = createRef<HTMLLIElement>()
}
}
}
if (Object.keys(refs).length > 0) {
setLiRefs(refs)
}
}
},
[eventIds, inCommon]
)

function onOwnerEnter(ownerEventId: number, owner: string): void {
if (
owner in adressesColors &&
settings &&
settings.autoScrollCollectors
) {
for (const eventId of eventIds) {
if (eventId !== ownerEventId &&
eventId && liRefs &&
owner in liRefs[eventId] &&
liRefs[eventId][owner].current) {
liRefs[eventId][owner].current.scrollIntoView({
behavior: 'smooth',
block: 'center',
})
}
}
if (
ownerEventId in liRefs &&
owner in liRefs[ownerEventId] &&
liRefs[ownerEventId][owner].current
) {
liRefs[ownerEventId][owner].current.scrollIntoView({
behavior: 'smooth',
block: 'center',
})
}
}
setHighlighted((current) => (
current !== owner &&
owner in adressesColors
Expand Down Expand Up @@ -154,11 +104,6 @@ function EventsCompare({
return (
<li
key={owner}
ref={
eventId in liRefs &&
owner in liRefs[eventId]
? liRefs[eventId][owner]
: undefined}
style={{
backgroundColor:
owner in adressesColors &&
Expand Down
6 changes: 2 additions & 4 deletions src/hooks/useCollectionSearch.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useCallback, useState } from 'react'
import { useSettings } from 'stores/settings'
import { SEARCH_LIMIT } from 'models/event'
import { searchCollections as loadSearchCollections } from 'loaders/collection'
import { AbortedError } from 'models/error'
Expand All @@ -13,7 +12,6 @@ function useCollectionSearch(query?: string, page: number = 1): {
searchCollections: (newQuery?: string | null, newPage?: number) => () => void
retryCollectionSearch: () => void
} {
const { settings } = useSettings()
const [loading, setLoading] = useState<boolean>(false)
const [error, setError] = useState<Error | null>(null)
const [total, setTotal] = useState<number | null>(null)
Expand All @@ -29,7 +27,7 @@ function useCollectionSearch(query?: string, page: number = 1): {
setTotal(null)
setResultCollections([])
const offset = ((newPage ?? page) - 1) * SEARCH_LIMIT
if (settings.showCollections && (total == null || offset <= total)) {
if (total == null || offset <= total) {
controller = new AbortController()
setLoading(true)
loadSearchCollections(
Expand Down Expand Up @@ -74,7 +72,7 @@ function useCollectionSearch(query?: string, page: number = 1): {
setResultCollections([])
}
},
[query, page, total, settings.showCollections]
[query, page, total]
)

function retryCollectionSearch(): void {
Expand Down
43 changes: 19 additions & 24 deletions src/hooks/useEventsCollections.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useCallback, useState } from 'react'
import { AbortedError } from 'models/error'
import { useSettings } from 'stores/settings'
import { findEventsCollections } from 'loaders/collection'

function useEventsCollections(eventIds: number[]): {
Expand All @@ -10,35 +9,31 @@ function useEventsCollections(eventIds: number[]): {
relatedCollections: Awaited<ReturnType<typeof findEventsCollections>>['related'] | null
fetchEventsCollections: () => () => void
} {
const { settings } = useSettings()
const [loading, setLoading] = useState<boolean>(false)
const [error, setError] = useState<Error | null>(null)
const [result, setResult] = useState<Awaited<ReturnType<typeof findEventsCollections>> | null>(null)

const fetchEventsCollections = useCallback(
() => {
let controller: AbortController | undefined
if (settings.showCollections) {
controller = new AbortController()
setLoading(true)
findEventsCollections(
eventIds,
controller.signal
).then((result) => {
setResult(result)
setLoading(false)
}).catch((err: unknown) => {
setLoading(false)
if (!(err instanceof AbortedError)) {
console.error(err)
if (err instanceof Error) {
setError(err)
} else {
setError(new Error(`Could not load collections`, { cause: err }))
}
const controller = new AbortController()
setLoading(true)
findEventsCollections(
eventIds,
controller.signal
).then((result) => {
setResult(result)
setLoading(false)
}).catch((err: unknown) => {
setLoading(false)
if (!(err instanceof AbortedError)) {
console.error(err)
if (err instanceof Error) {
setError(err)
} else {
setError(new Error(`Could not load collections`, { cause: err }))
}
})
}
}
})
return () => {
if (controller) {
controller.abort()
Expand All @@ -48,7 +43,7 @@ function useEventsCollections(eventIds: number[]): {
setResult(null)
}
},
[eventIds, settings.showCollections]
[eventIds]
)

return {
Expand Down
9 changes: 0 additions & 9 deletions src/models/settings.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
export const DEFAULT_SETTINGS = {
welcomeShown: false,
feedbackShown: false,

showLastEvents: true,
autoScrollCollectors: true,
openProfiles: true,
showCollections: true,
}

export interface Settings {
welcomeShown: boolean
feedbackShown: boolean
showLastEvents: boolean
autoScrollCollectors: boolean
openProfiles: boolean
showCollections: boolean
}
Loading

0 comments on commit 56b72d5

Please sign in to comment.