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"
|
title="media-description"
|
||||||
/>}
|
/>}
|
||||||
<div className={classes.infoBox}>
|
<div className={classes.infoBox}>
|
||||||
<LinearProgress
|
{amountsPledged[0] ? <LinearProgress
|
||||||
classes={{
|
classes={{
|
||||||
colorPrimary: classes.linearColorPrimary,
|
colorPrimary: classes.linearColorPrimary,
|
||||||
barColorPrimary: classes.linearBarColorPrimary,
|
barColorPrimary: classes.linearBarColorPrimary,
|
||||||
}}
|
}}
|
||||||
variant="determinate"
|
variant="determinate"
|
||||||
value={percentToGoal}
|
value={percentToGoal}
|
||||||
/>
|
/> : <LinearProgress />}
|
||||||
<div className={classes.infoBoxSection}>
|
<div className={classes.infoBoxSection}>
|
||||||
<span className={classes.raisedAmount}>
|
<span className={classes.raisedAmount}>
|
||||||
{`${totalPledged.toLocaleString()} ${amountsPledged[0] ? amountsPledged[0][0] : ''}`}
|
{`${totalPledged.toLocaleString()} ${amountsPledged[0] ? amountsPledged[0][0] : ''}`}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
|
import EmbarkJS from 'Embark/EmbarkJS'
|
||||||
import web3 from 'Embark/web3'
|
import web3 from 'Embark/web3'
|
||||||
|
import LiquidPledging from 'Embark/contracts/LiquidPledging'
|
||||||
import { useState, useEffect, useMemo } from 'react'
|
import { useState, useEffect, useMemo } from 'react'
|
||||||
import { timeSinceBlock } from '../../utils/dates'
|
import { timeSinceBlock } from '../../utils/dates'
|
||||||
import { getFiles } from '../../utils/ipfs'
|
import { getFiles } from '../../utils/ipfs'
|
||||||
|
@ -9,16 +11,18 @@ async function getProjectAge(id, events, setState){
|
||||||
setState(timeSinceBlock(timestamp, 'days'))
|
setState(timeSinceBlock(timestamp, 'days'))
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getProjectAssets(hash, setState){
|
async function getProjectAssets(projectId, setState){
|
||||||
console.log({hash})
|
EmbarkJS.onReady(async (err) => {
|
||||||
const CID = hash.split('/').slice(-1)[0]
|
const projectInfo = await LiquidPledging.methods.getPledgeAdmin(projectId).call()
|
||||||
getFiles(CID)
|
const CID = projectInfo.url.split('/').slice(-1)[0]
|
||||||
.then((files) => {
|
getFiles(CID)
|
||||||
setState(files)
|
.then((files) => {
|
||||||
const manifest = files[2]
|
setState(files)
|
||||||
console.log({files}, JSON.parse(manifest.content))
|
const manifest = files[2]
|
||||||
})
|
console.log({files}, JSON.parse(manifest.content))
|
||||||
.catch(console.log)
|
})
|
||||||
|
.catch(console.log)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const getProjectManifest = assets => assets ? JSON.parse(assets.find(a => a.name.toLowerCase() === 'manifest.json').content) : null
|
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])
|
}, [projectAddedEvents])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (profile[0]) getProjectAssets(profile[0].url, setAssets)
|
getProjectAssets(projectId, setAssets)
|
||||||
}, [profile])
|
}, [projectId])
|
||||||
|
|
||||||
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets])
|
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue