mirror of
https://github.com/stronk-dev/RandomChad.git
synced 2025-07-05 10:35:08 +02:00
✨ add ids to multiple rocketeer endpoint and remove website link testing
This commit is contained in:
parent
e47a1054b7
commit
30057f43ed
4
.github/workflows/deploy-website.yml
vendored
4
.github/workflows/deploy-website.yml
vendored
@ -49,10 +49,6 @@ jobs:
|
|||||||
run: npm i
|
run: npm i
|
||||||
working-directory: website
|
working-directory: website
|
||||||
|
|
||||||
- name: test if all links work
|
|
||||||
run: npm test
|
|
||||||
working-directory: website
|
|
||||||
|
|
||||||
- name: Build website files
|
- name: Build website files
|
||||||
env:
|
env:
|
||||||
NODE_ENV: production
|
NODE_ENV: production
|
||||||
|
@ -155,8 +155,11 @@ async function safelyReturnMultipleRocketeers( ids=[], network='mainnet' ) {
|
|||||||
const invalidIds = await Promise.all( ids.map( id => isInvalidRocketeerId( id, network ) ) )
|
const invalidIds = await Promise.all( ids.map( id => isInvalidRocketeerId( id, network ) ) )
|
||||||
if( invalidIds.includes( true ) ) throw invalidIds
|
if( invalidIds.includes( true ) ) throw invalidIds
|
||||||
|
|
||||||
// Get old rocketeers
|
// Get old rocketeers and append their ids
|
||||||
const rocketeers = await Promise.all( ids.map( id => getExistingRocketeer( id ) ) )
|
const rocketeers = await Promise.all( ids.map( async id => ( {
|
||||||
|
...await getExistingRocketeer( id ),
|
||||||
|
id: id
|
||||||
|
} ) ) )
|
||||||
|
|
||||||
// Send back an array of rocketeers, but not any failed ones
|
// Send back an array of rocketeers, but not any failed ones
|
||||||
return rocketeers.filter( rocketeer => rocketeer )
|
return rocketeers.filter( rocketeer => rocketeer )
|
||||||
|
@ -42,21 +42,32 @@ export function useRocketeers( onlyGrabThisId ) {
|
|||||||
const ids = onlyGrabThisId ? [ onlyGrabThisId ] : tokenIds
|
const ids = onlyGrabThisId ? [ onlyGrabThisId ] : tokenIds
|
||||||
const [ rocketeers, setRocketeers ] = useState( [] )
|
const [ rocketeers, setRocketeers ] = useState( [] )
|
||||||
|
|
||||||
useEffect( f => {
|
useEffect( ( ) => {
|
||||||
|
|
||||||
( async function() {
|
let cancelled = false;
|
||||||
|
|
||||||
const rocketeerMetas = await Promise.all( ids.map( async id => ( {
|
( async () => {
|
||||||
...await callApi( `/rocketeer/${ id }` ),
|
|
||||||
id: id
|
try {
|
||||||
} ) ) )
|
|
||||||
|
if( !ids.length || cancelled ) return
|
||||||
|
const rocketeerMetas = await callApi( `/rocketeers/?ids=${ ids.join( ',' ) }` )
|
||||||
log( 'Received rocketeers: ', rocketeerMetas )
|
log( 'Received rocketeers: ', rocketeerMetas )
|
||||||
setRocketeers( rocketeerMetas )
|
if( !cancelled ) setRocketeers( rocketeerMetas )
|
||||||
|
|
||||||
|
} catch( e ) {
|
||||||
|
|
||||||
|
} finally {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
} )( )
|
} )( )
|
||||||
|
|
||||||
|
return () => cancelled = true
|
||||||
|
|
||||||
}, [ tokenIds, onlyGrabThisId ] )
|
}, [ tokenIds, onlyGrabThisId ] )
|
||||||
|
|
||||||
|
|
||||||
return rocketeers
|
return rocketeers
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -65,16 +76,18 @@ export function useRocketeerImages() {
|
|||||||
|
|
||||||
const ids = useTokenIds()
|
const ids = useTokenIds()
|
||||||
const chainId = useChainId()
|
const chainId = useChainId()
|
||||||
|
const rocketeers = useRocketeers()
|
||||||
const [ images, setImages ] = useState( [] )
|
const [ images, setImages ] = useState( [] )
|
||||||
|
|
||||||
useEffect( f => {
|
useEffect( f => {
|
||||||
|
|
||||||
|
if( rocketeers.length ) setImages( rocketeers.map( ( { image, id }, i ) => ( { src: image, id: id || i } ) ) )
|
||||||
setImages( ids.map( id => ( {
|
setImages( ids.map( id => ( {
|
||||||
id,
|
id,
|
||||||
src: getImage( id, 'jpg', chainId === '0x1' ? 'mainnet' : 'testnet' )
|
src: getImage( id, 'jpg', chainId === '0x1' ? 'mainnet' : 'testnet' )
|
||||||
} ) ) )
|
} ) ) )
|
||||||
|
|
||||||
}, [ ids, chainId ] )
|
}, [ ids, chainId, rocketeers ] )
|
||||||
|
|
||||||
return images
|
return images
|
||||||
|
|
||||||
|
@ -216,6 +216,7 @@ export function useChainId() {
|
|||||||
export function useTokenIds() {
|
export function useTokenIds() {
|
||||||
|
|
||||||
// Deps
|
// Deps
|
||||||
|
const chain = useChainId()
|
||||||
const address = useAddress()
|
const address = useAddress()
|
||||||
const contract = useContract()
|
const contract = useContract()
|
||||||
const balance = useBalanceOf()
|
const balance = useBalanceOf()
|
||||||
@ -253,7 +254,7 @@ export function useTokenIds() {
|
|||||||
|
|
||||||
return () => cancelled = true
|
return () => cancelled = true
|
||||||
|
|
||||||
}, [ contract, address, balance ] )
|
}, [ contract, address, balance, chain ] )
|
||||||
|
|
||||||
|
|
||||||
return tokens
|
return tokens
|
||||||
|
Loading…
x
Reference in New Issue
Block a user