add faster load time to project page
This commit is contained in:
parent
3b5c1b6897
commit
b03c338500
|
@ -213,14 +213,14 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
|
|||
title="media-description"
|
||||
/>}
|
||||
<div className={classes.infoBox}>
|
||||
<LinearProgress
|
||||
{amountsPledged[0] ? <LinearProgress
|
||||
classes={{
|
||||
colorPrimary: classes.linearColorPrimary,
|
||||
barColorPrimary: classes.linearBarColorPrimary,
|
||||
}}
|
||||
variant="determinate"
|
||||
value={percentToGoal}
|
||||
/>
|
||||
/> : <LinearProgress />}
|
||||
<div className={classes.infoBoxSection}>
|
||||
<span className={classes.raisedAmount}>
|
||||
{`${totalPledged.toLocaleString()} ${amountsPledged[0] ? amountsPledged[0][0] : ''}`}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import EmbarkJS from 'Embark/EmbarkJS'
|
||||
import web3 from 'Embark/web3'
|
||||
import LiquidPledging from 'Embark/contracts/LiquidPledging'
|
||||
import { useState, useEffect, useMemo } from 'react'
|
||||
import { timeSinceBlock } from '../../utils/dates'
|
||||
import { getFiles } from '../../utils/ipfs'
|
||||
|
@ -9,9 +11,10 @@ async function getProjectAge(id, events, setState){
|
|||
setState(timeSinceBlock(timestamp, 'days'))
|
||||
}
|
||||
|
||||
async function getProjectAssets(hash, setState){
|
||||
console.log({hash})
|
||||
const CID = hash.split('/').slice(-1)[0]
|
||||
async function getProjectAssets(projectId, setState){
|
||||
EmbarkJS.onReady(async (err) => {
|
||||
const projectInfo = await LiquidPledging.methods.getPledgeAdmin(projectId).call()
|
||||
const CID = projectInfo.url.split('/').slice(-1)[0]
|
||||
getFiles(CID)
|
||||
.then((files) => {
|
||||
setState(files)
|
||||
|
@ -19,6 +22,7 @@ async function getProjectAssets(hash, setState){
|
|||
console.log({files}, JSON.parse(manifest.content))
|
||||
})
|
||||
.catch(console.log)
|
||||
})
|
||||
}
|
||||
|
||||
const getProjectManifest = assets => assets ? JSON.parse(assets.find(a => a.name.toLowerCase() === 'manifest.json').content) : null
|
||||
|
@ -32,8 +36,8 @@ export function useProjectData(projectId, profile, projectAddedEvents) {
|
|||
}, [projectAddedEvents])
|
||||
|
||||
useEffect(() => {
|
||||
if (profile[0]) getProjectAssets(profile[0].url, setAssets)
|
||||
}, [profile])
|
||||
getProjectAssets(projectId, setAssets)
|
||||
}, [projectId])
|
||||
|
||||
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets])
|
||||
|
||||
|
|
Loading…
Reference in New Issue