ensure refresh of data when project id changes
This commit is contained in:
parent
99a57c8b92
commit
d8c41c099f
|
@ -193,11 +193,11 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
|
||||||
const projectId = match.params.id
|
const projectId = match.params.id
|
||||||
const { projectAge, projectAssets, manifest } = useProjectData(projectId, profile, projectAddedEvents)
|
const { projectAge, projectAssets, manifest } = useProjectData(projectId, profile, projectAddedEvents)
|
||||||
|
|
||||||
const amountsPledged = useMemo(() => getAmountsPledged(pledges), [pledges])
|
const amountsPledged = useMemo(() => getAmountsPledged(pledges), [pledges, projectId])
|
||||||
const numberOfBackers = useMemo(() => getNumberOfBackers(pledges), [pledges])
|
const numberOfBackers = useMemo(() => getNumberOfBackers(pledges), [pledges, projectId])
|
||||||
const mediaType = useMemo(() => getMediaType(projectAssets), [projectAssets])
|
const mediaType = useMemo(() => getMediaType(projectAssets), [projectAssets, projectId])
|
||||||
const mediaUrl = useMemo(() => getMediaSrc(projectAssets), [projectAssets])
|
const mediaUrl = useMemo(() => getMediaSrc(projectAssets), [projectAssets, projectId])
|
||||||
const avatarUrl = useMemo(() => getAvatarSrc(projectAssets), [projectAssets])
|
const avatarUrl = useMemo(() => getAvatarSrc(projectAssets), [projectAssets, projectId])
|
||||||
const totalPledged = amountsPledged[0] ? amountsPledged[0][1] : 0
|
const totalPledged = amountsPledged[0] ? amountsPledged[0][1] : 0
|
||||||
const percentToGoal = manifest ? Math.min(
|
const percentToGoal = manifest ? Math.min(
|
||||||
(Number(totalPledged) / Number(manifest.goal)) * 100,
|
(Number(totalPledged) / Number(manifest.goal)) * 100,
|
||||||
|
@ -232,7 +232,7 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
|
||||||
title="media-description"
|
title="media-description"
|
||||||
/>}
|
/>}
|
||||||
<div className={classes.infoBox}>
|
<div className={classes.infoBox}>
|
||||||
{amountsPledged[0] ? <LinearProgress
|
{mediaUrl ? <LinearProgress
|
||||||
classes={{
|
classes={{
|
||||||
colorPrimary: classes.linearColorPrimary,
|
colorPrimary: classes.linearColorPrimary,
|
||||||
barColorPrimary: classes.linearBarColorPrimary,
|
barColorPrimary: classes.linearBarColorPrimary,
|
||||||
|
@ -270,7 +270,7 @@ Project.propTypes = {
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledProject = withStyles(styles)(Project)
|
const StyledProject = withStyles(styles)(Project)
|
||||||
export default withDatabase(withObservables([], ({ database, match }) => ({
|
export default withDatabase(withObservables(['match'], ({ database, match }) => ({
|
||||||
profile: database.collections.get('profiles').query(
|
profile: database.collections.get('profiles').query(
|
||||||
Q.where('id_profile', match.params.id)
|
Q.where('id_profile', match.params.id)
|
||||||
).observe(),
|
).observe(),
|
||||||
|
|
|
@ -96,13 +96,13 @@ export function useProjectData(projectId, profile, projectAddedEvents) {
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProjectAge(projectId, projectAddedEvents, setAge)
|
getProjectAge(projectId, projectAddedEvents, setAge)
|
||||||
}, [projectAddedEvents])
|
}, [projectAddedEvents, projectId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProjectAssets(projectId, setAssets)
|
getProjectAssets(projectId, setAssets)
|
||||||
}, [projectId, ipfsReady])
|
}, [projectId, ipfsReady])
|
||||||
|
|
||||||
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets])
|
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets, projectId])
|
||||||
|
|
||||||
return {
|
return {
|
||||||
projectAge,
|
projectAge,
|
||||||
|
|
Loading…
Reference in New Issue