fallback to fetch files from web if ipfs node fails
redirect on page create to fund-project path
This commit is contained in:
parent
3645ba787e
commit
ea7c90efe9
|
@ -210,7 +210,7 @@ const SubmissionSection = ({ classes, history }) => {
|
||||||
console.log({res})
|
console.log({res})
|
||||||
openSnackBar('success', addProjectSucessMsg(res))
|
openSnackBar('success', addProjectSucessMsg(res))
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
history.push(`/project/${getProjectId(res)}`)
|
history.push(`/fund-project/${getProjectId(res)}`)
|
||||||
resetForm()
|
resetForm()
|
||||||
}, 5000)
|
}, 5000)
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,7 @@ import LiquidPledging from '../../embarkArtifacts/contracts/LiquidPledging'
|
||||||
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'
|
||||||
import { getFiles, ipfs } from '../../utils/ipfs'
|
import { getFiles, getFilesWeb, ipfs } from '../../utils/ipfs'
|
||||||
import { databaseExists } from '../../utils/db'
|
import { databaseExists } from '../../utils/db'
|
||||||
import { arrayToObject } from '../../utils/array'
|
import { arrayToObject } from '../../utils/array'
|
||||||
import { FundingContext } from '../../context'
|
import { FundingContext } from '../../context'
|
||||||
|
@ -45,7 +45,7 @@ async function getProjectAssets(projectId, setState, debug=false){
|
||||||
databaseExists('ipfs')
|
databaseExists('ipfs')
|
||||||
.catch(() => window.location.reload())
|
.catch(() => window.location.reload())
|
||||||
|
|
||||||
getFiles(CID)
|
getFilesWeb(CID)
|
||||||
.then((files) => {
|
.then((files) => {
|
||||||
setState(files)
|
setState(files)
|
||||||
const manifest = files[2]
|
const manifest = files[2]
|
||||||
|
|
|
@ -129,6 +129,16 @@ export const getFiles = CID => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getFilesWeb = CID => {
|
||||||
|
const clean = CID.split('/').slice(-1)[0]
|
||||||
|
return new Promise(function(resolve, reject) {
|
||||||
|
ipfsHttp.get(clean, (err, files) => {
|
||||||
|
if (err) reject(err)
|
||||||
|
else resolve(files)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export const isWeb = str => str.includes('http')
|
export const isWeb = str => str.includes('http')
|
||||||
export const formatMedia = str => {
|
export const formatMedia = str => {
|
||||||
return isWeb(str) ? str : `/root/${str}`
|
return isWeb(str) ? str : `/root/${str}`
|
||||||
|
|
Loading…
Reference in New Issue