mirror of
https://github.com/status-im/liquid-funding.git
synced 2025-02-26 18:10:37 +00:00
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 Button from '@material-ui/core/Button'
|
||||||
import Typography from '@material-ui/core/Typography'
|
import Typography from '@material-ui/core/Typography'
|
||||||
import { withStyles } from '@material-ui/core/styles'
|
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 { FundingContext } from '../../context'
|
||||||
import TextDisplay from '../base/TextDisplay'
|
import TextDisplay from '../base/TextDisplay'
|
||||||
import Icon from '../base/icons/IconByName'
|
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 projectId = match.params.id
|
||||||
const { loading, error, data } = useQuery(getProfileById, {
|
const { loading, error, data } = useQuery(getProfileById, {
|
||||||
variables: { id: formatProjectId(projectId) }
|
variables: { id: formatProjectId(projectId) }
|
||||||
});
|
});
|
||||||
const projectData = useProjectData(projectId, projectAddedEvents, data)
|
const projectData = useProjectData(projectId, data)
|
||||||
|
|
||||||
if (loading) return <Loading />
|
if (loading) return <Loading />
|
||||||
if (error) return <div>{`Error! ${error.message}`}</div>
|
if (error) return <div>{`Error! ${error.message}`}</div>
|
||||||
if(!data.profile) return <Typography className={classes.noProject}>Project Not Found</Typography>
|
if(!data.profile) return <Typography className={classes.noProject}>Project Not Found</Typography>
|
||||||
|
|
||||||
console.log({loading,error,data})
|
|
||||||
|
|
||||||
const commitTime = convertToHours(data.profile.commitTime)
|
const commitTime = convertToHours(data.profile.commitTime)
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
@ -201,12 +196,4 @@ function FundProject({ classes, match, history, projectAddedEvents }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const StyledProject = withStyles(styles)(FundProject)
|
export default 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))
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
/*global web3*/
|
|
||||||
import { useState, useEffect, useMemo, useContext } from 'react'
|
import { useState, useEffect, useMemo, useContext } from 'react'
|
||||||
import { unnest } from 'ramda'
|
import { unnest } from 'ramda'
|
||||||
import { timeSinceBlock } from '../../utils/dates'
|
import { timeSinceBlock } from '../../utils/dates'
|
||||||
@ -9,22 +8,18 @@ import { FundingContext } from '../../context'
|
|||||||
import { getDelegateProfiles } from '../../actions/profiles'
|
import { getDelegateProfiles } from '../../actions/profiles'
|
||||||
import { getDelegatePledgesByProfile } from '../../actions/delegates'
|
import { getDelegatePledgesByProfile } from '../../actions/delegates'
|
||||||
|
|
||||||
async function getProjectAge(id, events, setState){
|
async function getProjectAge(data, setState){
|
||||||
const event = events.find(e => e.returnValues.idProject === id)
|
if (data.profile) {
|
||||||
if (event) {
|
setState(timeSinceBlock(data.profile.creationTime, 'days'))
|
||||||
const { timestamp } = await web3.eth.getBlock(event.blockNumber)
|
|
||||||
setState(timeSinceBlock(timestamp, 'days'))
|
|
||||||
} else {
|
} else {
|
||||||
setState(timeSinceBlock(false, 'days'))
|
setState(timeSinceBlock(false, 'days'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getProjectCreator(id, events, setState){
|
async function getProjectCreator(data, setState){
|
||||||
const event = events.find(e => e.returnValues.idProject === id)
|
if (!data.profile) return
|
||||||
if (event) {
|
const { addr } = data.profile
|
||||||
const { address } = event
|
setState(addr)
|
||||||
setState(address)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getProjectAssets(data, setState, debug=false){
|
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 [projectAge, setAge] = useState(null)
|
||||||
const [creator, setCreator] = useState(null)
|
const [creator, setCreator] = useState(null)
|
||||||
const [projectAssets, setAssets] = useState(null)
|
const [projectAssets, setAssets] = useState(null)
|
||||||
@ -126,12 +121,12 @@ export function useProjectData(projectId, projectAddedEvents, data) {
|
|||||||
}, [account])
|
}, [account])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProjectAge(projectId, projectAddedEvents, setAge)
|
getProjectAge(data, setAge)
|
||||||
}, [projectAddedEvents, projectId])
|
}, [data, projectId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProjectCreator(projectId, projectAddedEvents, setCreator)
|
getProjectCreator(data, setCreator)
|
||||||
}, [projectAddedEvents, projectId])
|
}, [data, projectId])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProjectAssets(data, setAssets)
|
getProjectAssets(data, setAssets)
|
||||||
|
@ -9,7 +9,8 @@ query Profile($id: ID!){
|
|||||||
url,
|
url,
|
||||||
profileId,
|
profileId,
|
||||||
type,
|
type,
|
||||||
name
|
name,
|
||||||
|
creationTime,
|
||||||
pledgesInfos {
|
pledgesInfos {
|
||||||
id
|
id
|
||||||
token
|
token
|
||||||
|
Loading…
x
Reference in New Issue
Block a user