1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00

periodically try to get DDO when not present yet

This commit is contained in:
Matthias Kretschmann 2020-10-21 16:43:23 +02:00
parent cc2474419b
commit 89709cbe73
Signed by: m
GPG Key ID: 606EEEF3C479A91F
3 changed files with 13 additions and 5 deletions

View File

@ -16,9 +16,9 @@ export default function Datatoken(props: InputProps): ReactElement {
helpers.setValue({ ...dataTokenOptions }) helpers.setValue({ ...dataTokenOptions })
} }
// Generate new DT name & symbol, but only once automatically // Generate new DT name & symbol
useEffect(() => { useEffect(() => {
if (!ocean || typeof field?.value?.name !== 'undefined') return if (!ocean) return
generateName() generateName()
}, [ocean]) }, [ocean])

View File

@ -23,7 +23,7 @@ export default function Feedback({
<Button <Button
style="primary" style="primary"
size="small" size="small"
href={`/asset/${ddo?.id}`} to={`/asset/${ddo?.id}`}
className={styles.action} className={styles.action}
> >
Go to data set Go to data set

View File

@ -23,13 +23,17 @@ export default function PageTemplateAssetDetails({
useEffect(() => { useEffect(() => {
async function init() { async function init() {
if (ddo) return
try { try {
const metadataCache = new MetadataCache(config.metadataCacheUri, Logger) const metadataCache = new MetadataCache(config.metadataCacheUri, Logger)
const ddo = await metadataCache.retrieveDDO(did) const ddo = await metadataCache.retrieveDDO(did)
if (!ddo) { if (!ddo) {
setTitle('Could not retrieve asset') setTitle('Could not retrieve asset')
setError('The DDO was not found in MetadataCache.') setError(
`The DDO for ${did} was not found in MetadataCache. If you just published a new data set, wait some seconds and refresh this page.`
)
return return
} }
@ -44,7 +48,11 @@ export default function PageTemplateAssetDetails({
} }
} }
init() init()
}, [did, config.metadataCacheUri])
// Periodically try to get DDO when not present yet
const timer = !ddo && setInterval(() => init(), 2000)
return () => clearInterval(timer)
}, [ddo, did, config.metadataCacheUri])
return did && metadata ? ( return did && metadata ? (
<Layout title={title} uri={uri}> <Layout title={title} uri={uri}>