fetch project info from subgraph

This commit is contained in:
Barry Gitarts 2019-08-19 11:59:05 -04:00 committed by Barry G
parent 1ae15cdbe3
commit 47dd9320cb
3 changed files with 30 additions and 3 deletions

View File

@ -32,7 +32,6 @@ export const batchAddPledges = async (pledges, profiles = []) => {
const batch = pledges.map(data => { const batch = pledges.map(data => {
return pledgesCollection.prepareCreate(pledge => createPledge(pledge, data, profiles)) return pledgesCollection.prepareCreate(pledge => createPledge(pledge, data, profiles))
}) })
console.log({batch})
return await database.action(async () => await database.batch(...batch)) return await database.action(async () => await database.batch(...batch))
} }

View File

@ -89,10 +89,23 @@ const isManifest = asset => {
const name = asset.path.split('/').slice(-1)[0] const name = asset.path.split('/').slice(-1)[0]
return name.toLowerCase() === 'manifest.json' return name.toLowerCase() === 'manifest.json'
} }
const getProjectManifest = assets => { const getProjectManifest = (data, assets) => {
if (data && data.profile && data.profile.projectInfo) {
const { isPlaying, type, file } = data.profile.projectInfo
return {
...data.profile.projectInfo,
media: {
isPlaying,
type,
file
}
}
}
if (!assets) { if (!assets) {
return null; return null;
} }
const manifest = assets.find(isManifest); const manifest = assets.find(isManifest);
if (!manifest) { if (!manifest) {
return null; return null;
@ -132,7 +145,7 @@ export function useProjectData(projectId, data) {
getProjectAssets(data, setAssets) getProjectAssets(data, setAssets)
}, [ipfsReady, data]) }, [ipfsReady, data])
const manifest = useMemo(() => getProjectManifest(projectAssets), [projectAssets, projectId]) const manifest = useMemo(() => getProjectManifest(data, projectAssets), [data, projectAssets, projectId])
return { return {
account, account,

View File

@ -17,6 +17,21 @@ query Profile($id: ID!){
lifetimeReceived lifetimeReceived
balance balance
} }
projectInfo{
id
title
subtitle
creator
repo
avatar
goal
goalToken
description
chatRoom
file
type
isPlaying
}
} }
} }
` `