load project page with no media assets

This commit is contained in:
Barry Gitarts 2019-05-28 14:55:45 -04:00 committed by Barry G
parent 6a4fb86cd3
commit 128aba33db
1 changed files with 8 additions and 2 deletions

View File

@ -1,3 +1,4 @@
/*eslint complexity: ["error", 25]*/
/*global web3*/ /*global web3*/
import React, { useMemo, Fragment } from 'react' import React, { useMemo, Fragment } from 'react'
import { Link } from 'react-router-dom' import { Link } from 'react-router-dom'
@ -21,6 +22,9 @@ import { getFiles } from '../../utils/ipfs'
import { getImageType } from '../../utils/images' import { getImageType } from '../../utils/images'
import { useProjectData } from './hooks' import { useProjectData } from './hooks'
const ROOT_PATH = '/root/'
const DEFAULT_AVATAR = 'https://our.status.im/content/images/2018/07/status_logo_blue_1--2-.png'
const styles = theme => ({ const styles = theme => ({
root: { root: {
display: 'grid', display: 'grid',
@ -173,6 +177,7 @@ const getMediaSrc = assets => {
const getAvatarSrc = assets => { const getAvatarSrc = assets => {
if (!assets) return null if (!assets) return null
const { avatar } = getProjectManifest(assets) const { avatar } = getProjectManifest(assets)
if (!avatar || avatar === ROOT_PATH) return DEFAULT_AVATAR
if (avatar.includes('http')) return avatar if (avatar.includes('http')) return avatar
const type = getImageType(avatar) const type = getImageType(avatar)
return formatAvatar( return formatAvatar(
@ -200,6 +205,7 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
const addr = profile[0] ? profile[0].addr.toUpperCase() : null const addr = profile[0] ? profile[0].addr.toUpperCase() : null
const accountUpper = account ? account.toUpperCase() : account const accountUpper = account ? account.toUpperCase() : account
const userIsOwner = addr === accountUpper const userIsOwner = addr === accountUpper
const mediaSrc = mediaUrl || DEFAULT_AVATAR
console.log({profile, projectAssets, mediaUrl, mediaType, amountsPledged, pledges, transfers, match}) console.log({profile, projectAssets, mediaUrl, mediaType, amountsPledged, pledges, transfers, match})
return (<Fragment> return (<Fragment>
{!projectAssets && <Loading/>} {!projectAssets && <Loading/>}
@ -223,11 +229,11 @@ function Project({ classes, match, profile, transfers, pledges, projectAddedEven
component="img" component="img"
alt="video" alt="video"
className={classes.media} className={classes.media}
src={mediaUrl} src={mediaSrc}
title="media-description" title="media-description"
/>} />}
<div className={classes.infoBox}> <div className={classes.infoBox}>
{mediaUrl ? <LinearProgress {mediaUrl || avatarUrl ? <LinearProgress
classes={{ classes={{
colorPrimary: classes.linearColorPrimary, colorPrimary: classes.linearColorPrimary,
barColorPrimary: classes.linearBarColorPrimary, barColorPrimary: classes.linearBarColorPrimary,