Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPFS hash to link and creator address #49

Merged
merged 5 commits into from
Mar 20, 2020
Merged

Conversation

rperez89
Copy link
Member

@rperez89 rperez89 commented Mar 20, 2020

this closes #47 #48

@rperez89 rperez89 changed the title hash to link IPFS hash to link and creator address Mar 20, 2020
Copy link
Member

@fabriziovigevani fabriziovigevani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

Left a couple of suggestions and we should also keep the creator between delay script updates.

const { timestamp } = await getBlock(blockNumber) // TODO: Move to getDelayedScript (keep in mind that updateScript also calls this function)
const delayedScript = {
...(await getDelayedScript(scriptId, blockNumber)),
timeSubmitted: marshallDate(timestamp),
totalTimePaused: 0,
creator,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also save this prop when the script is updated (e.g when the script is paused or resumed) otherwise we would lose this information.

This can be achieved at

function mergeScripts(oldScript, newScript) {
where we get the creator from oldScript

@@ -34,7 +36,14 @@ const ScriptText = React.memo(
<LocalIdentityBadge badgeOnly={disabled} compact entity={part} />
</span>
) : (
<span key={index}>{part}</span>
transformIPFSHash(part, (word, isIpfs, i) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we reword isIpfs to isIpfsHash for consistency? Also i think we could wrap all this into a <React.Fragment /> and pass as key the index from transformAddress

And then use this i index to the components we render below <Link /> or <span/>

Comment on lines 40 to 46
const ipfsUrl = generateURI(word)
return isIpfs ? (
<Link href={ipfsUrl}>{ipfsUrl} </Link>
) : (
<span key={index}>{word}</span>
)
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of reafctoring this to something like:

Suggested change
const ipfsUrl = generateURI(word)
return isIpfs ? (
<Link href={ipfsUrl}>{ipfsUrl} </Link>
) : (
<span key={index}>{word}</span>
)
})
if (isIpfs) {
const ipfsUrl = generateURI(word)
return <Link href={ipfsUrl}>{ipfsUrl} </Link>
}
return <span key={index}>{word}</span>
})

So we don't generate the URI in case it's not an ipfsHash

@fabriziovigevani fabriziovigevani merged commit 4fff92c into master Mar 20, 2020
@fabriziovigevani fabriziovigevani deleted the ipfsHash-to-Link branch March 20, 2020 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

detect ipfs hashes in radspec and link them
2 participants