remove watermelon queries from fund project page
This commit is contained in:
parent
a664db1e73
commit
a0ca52fe07
|
@ -6,9 +6,6 @@ import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
|
|||
import Button from '@material-ui/core/Button'
|
||||
import Typography from '@material-ui/core/Typography'
|
||||
import { withStyles } from '@material-ui/core/styles'
|
||||
import withObservables from '@nozbe/with-observables'
|
||||
import { Q } from '@nozbe/watermelondb'
|
||||
import { withDatabase } from '@nozbe/watermelondb/DatabaseProvider'
|
||||
import { FundingContext } from '../../context'
|
||||
import TextDisplay from '../base/TextDisplay'
|
||||
import Icon from '../base/icons/IconByName'
|
||||
|
@ -173,19 +170,17 @@ const SubmissionSection = ({ classes, projectData, projectId, commitTime, profil
|
|||
)
|
||||
}
|
||||
|
||||
function FundProject({ classes, match, history, projectAddedEvents }) {
|
||||
function FundProject({ classes, match, history }) {
|
||||
const projectId = match.params.id
|
||||
const { loading, error, data } = useQuery(getProfileById, {
|
||||
variables: { id: formatProjectId(projectId) }
|
||||
});
|
||||
const projectData = useProjectData(projectId, projectAddedEvents, data)
|
||||
const projectData = useProjectData(projectId, data)
|
||||
|
||||
if (loading) return <Loading />
|
||||
if (error) return <div>{`Error! ${error.message}`}</div>
|
||||
if(!data.profile) return <Typography className={classes.noProject}>Project Not Found</Typography>
|
||||
|
||||
console.log({loading,error,data})
|
||||
|
||||
const commitTime = convertToHours(data.profile.commitTime)
|
||||
return (
|
||||
<div className={classes.root}>
|
||||
|
@ -201,12 +196,4 @@ function FundProject({ classes, match, history, projectAddedEvents }) {
|
|||
)
|
||||
}
|
||||
|
||||
const StyledProject = withStyles(styles)(FundProject)
|
||||
export default withDatabase(withObservables(['match'], ({ database }) => ({
|
||||
transfers: database.collections.get('lp_events').query(
|
||||
Q.where('event', 'Transfer')
|
||||
).observe(),
|
||||
projectAddedEvents: database.collections.get('lp_events').query(
|
||||
Q.where('event', 'ProjectAdded')
|
||||
).observe()
|
||||
}))(StyledProject))
|
||||
export default withStyles(styles)(FundProject)
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
/*global web3*/
|
||||
import { useState, useEffect, useMemo, useContext } from 'react'
|
||||
import { unnest } from 'ramda'
|
||||
import { timeSinceBlock } from '../../utils/dates'
|
||||
|
@ -9,22 +8,18 @@ import { FundingContext } from '../../context'
|
|||
import { getDelegateProfiles } from '../../actions/profiles'
|
||||
import { getDelegatePledgesByProfile } from '../../actions/delegates'
|
||||
|
||||
async function getProjectAge(id, events, setState){
|
||||
const event = events.find(e => e.returnValues.idProject === id)
|
||||
if (event) {
|
||||
const { timestamp } = await web3.eth.getBlock(event.blockNumber)
|
||||
setState(timeSinceBlock(timestamp, 'days'))
|
||||
async function getProjectAge(data, setState){
|
||||
if (data.profile) {
|
||||
setState(timeSinceBlock(data.profile.creationTime, 'days'))
|
||||
} else {
|
||||
setState(timeSinceBlock(false, 'days'))
|
||||
}
|
||||
}
|
||||
|
||||
async function getProjectCreator(id, events, setState){
|
||||
const event = events.find(e => e.returnValues.idProject === id)
|
||||
if (event) {
|
||||
const { address } = event
|
||||
setState(address)
|
||||
}
|
||||
async function getProjectCreator(data, setState){
|
||||
if (!data.profile) return
|
||||
const { addr } = data.profile
|
||||
setState(addr)
|
||||
}
|
||||
|
||||
async function getProjectAssets(data, setState, debug=false){
|
||||
|
@ -109,7 +104,7 @@ const getProjectManifest = assets => {
|
|||
}
|
||||
}
|
||||
|
||||
export function useProjectData(projectId, projectAddedEvents, data) {
|
||||
export function useProjectData(projectId, data) {
|
||||
const [projectAge, setAge] = useState(null)
|
||||
const [creator, setCreator] = useState(null)
|
||||
const [projectAssets, setAssets] = useState(null)
|
||||
|
@ -126,12 +121,12 @@ export function useProjectData(projectId, projectAddedEvents, data) {
|
|||
}, [account])
|
||||
|
||||
useEffect(() => {
|
||||
getProjectAge(projectId, projectAddedEvents, setAge)
|
||||
}, [projectAddedEvents, projectId])
|
||||
getProjectAge(data, setAge)
|
||||
}, [data, projectId])
|
||||
|
||||
useEffect(() => {
|
||||
getProjectCreator(projectId, projectAddedEvents, setCreator)
|
||||
}, [projectAddedEvents, projectId])
|
||||
getProjectCreator(data, setCreator)
|
||||
}, [data, projectId])
|
||||
|
||||
useEffect(() => {
|
||||
getProjectAssets(data, setAssets)
|
||||
|
|
|
@ -9,7 +9,8 @@ query Profile($id: ID!){
|
|||
url,
|
||||
profileId,
|
||||
type,
|
||||
name
|
||||
name,
|
||||
creationTime,
|
||||
pledgesInfos {
|
||||
id
|
||||
token
|
||||
|
|
Loading…
Reference in New Issue