ensure refresh of data when project id changes

This commit is contained in:
Barry Gitarts 2019-04-04 11:49:26 -04:00 committed by Barry G
parent 99a57c8b92
commit d8c41c099f
2 changed files with 9 additions and 9 deletions

View File

@ -193,11 +193,11 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
const projectId = match.params.id
const { projectAge, projectAssets, manifest } = useProjectData(projectId, profile, projectAddedEvents)
const amountsPledged = useMemo(() => getAmountsPledged(pledges), [pledges])
const numberOfBackers = useMemo(() => getNumberOfBackers(pledges), [pledges])
const mediaType = useMemo(() => getMediaType(projectAssets), [projectAssets])
const mediaUrl = useMemo(() => getMediaSrc(projectAssets), [projectAssets])
const avatarUrl = useMemo(() => getAvatarSrc(projectAssets), [projectAssets])
const amountsPledged = useMemo(() => getAmountsPledged(pledges), [pledges, projectId])
const numberOfBackers = useMemo(() => getNumberOfBackers(pledges), [pledges, projectId])
const mediaType = useMemo(() => getMediaType(projectAssets), [projectAssets, projectId])
const mediaUrl = useMemo(() => getMediaSrc(projectAssets), [projectAssets, projectId])
const avatarUrl = useMemo(() => getAvatarSrc(projectAssets), [projectAssets, projectId])
const totalPledged = amountsPledged[0] ? amountsPledged[0][1] : 0
const percentToGoal = manifest ? Math.min(
(Number(totalPledged) / Number(manifest.goal)) * 100,
@ -232,7 +232,7 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
title="media-description"
/>}
<div className={classes.infoBox}>
{amountsPledged[0] ? <LinearProgress
{mediaUrl ? <LinearProgress
classes={{
colorPrimary: classes.linearColorPrimary,
barColorPrimary: classes.linearBarColorPrimary,
@ -270,7 +270,7 @@ Project.propTypes = {
}
const StyledProject = withStyles(styles)(Project)
export default withDatabase(withObservables([], ({ database, match }) => ({
export default withDatabase(withObservables(['match'], ({ database, match }) => ({
profile: database.collections.get('profiles').query(
Q.where('id_profile', match.params.id)
).observe(),

View File

@ -96,13 +96,13 @@ export function useProjectData(projectId, profile, projectAddedEvents) {
useEffect(() => {
getProjectAge(projectId, projectAddedEvents, setAge)
}, [projectAddedEvents])
}, [projectAddedEvents, projectId])
useEffect(() => {
getProjectAssets(projectId, setAssets)
}, [projectId, ipfsReady])
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets])
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets, projectId])
return {
projectAge,