-
Notifications
You must be signed in to change notification settings - Fork 54
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
Upgrade discussions, improve documentation #1764
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,4 +1,4 @@ | ||||||
import React, { useState } from 'react' | ||||||
import React, { useState, useEffect, Fragment } from 'react' | ||||||
import PropTypes from 'prop-types' | ||||||
import styled from 'styled-components' | ||||||
import { format, formatDistance } from 'date-fns' | ||||||
|
@@ -10,6 +10,7 @@ const Header = styled.header` | |||||
display: flex; | ||||||
justify-content: space-between; | ||||||
margin-bottom: 10px; | ||||||
width: 100%; | ||||||
` | ||||||
|
||||||
const TimeAgo = styled.time.attrs(props => ({ | ||||||
|
@@ -23,11 +24,15 @@ TimeAgo.propTypes = { | |||||
date: PropTypes.instanceOf(Date).isRequired, | ||||||
} | ||||||
|
||||||
const Top = ({ author, createdAt }) => { | ||||||
const Top = ({ author, createdAt, identity }) => { | ||||||
const created = new Date(Number(createdAt) * 1000) | ||||||
return ( | ||||||
<Header> | ||||||
<IdentityBadge entity={author} /> | ||||||
{identity && identity.name ? ( | ||||||
<IdentityBadge entity={author} customLabel={identity.name} /> | ||||||
) : ( | ||||||
<IdentityBadge entity={author} /> | ||||||
)} | ||||||
<TimeAgo date={created} /> | ||||||
</Header> | ||||||
) | ||||||
|
@@ -112,18 +117,32 @@ const Bottom = ({ onDelete, onEdit }) => { | |||||
} | ||||||
|
||||||
const Comment = ({ | ||||||
app, | ||||||
currentUser, | ||||||
comment: { author, id, text, createdAt, revisions, postCid }, | ||||||
onDelete, | ||||||
onSave, | ||||||
}) => { | ||||||
const [editing, setEditing] = useState(false) | ||||||
const [identity, setIdentity] = useState(null) | ||||||
|
||||||
const update = async updated => { | ||||||
await onSave({ id, text: updated.text, revisions, postCid }) | ||||||
setEditing(false) | ||||||
} | ||||||
|
||||||
useEffect(() => { | ||||||
const resolveIdentity = async () => { | ||||||
const addressIdentity = await app | ||||||
.resolveAddressIdentity(author) | ||||||
.toPromise() | ||||||
if (addressIdentity) { | ||||||
setIdentity(addressIdentity) | ||||||
} | ||||||
} | ||||||
resolveIdentity() | ||||||
}, [author]) | ||||||
|
||||||
return ( | ||||||
<CommentCard> | ||||||
{editing ? ( | ||||||
|
@@ -133,13 +152,13 @@ const Comment = ({ | |||||
onSave={update} | ||||||
/> | ||||||
) : ( | ||||||
<React.Fragment> | ||||||
<Top author={author} createdAt={createdAt} /> | ||||||
<Fragment> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a big deal, but just note that recent react versions allow to omit the
Suggested change
|
||||||
<Top author={author} identity={identity} createdAt={createdAt} /> | ||||||
<Markdown content={text} /> | ||||||
{author === currentUser && ( | ||||||
<Bottom onDelete={onDelete} onEdit={() => setEditing(true)} /> | ||||||
)} | ||||||
</React.Fragment> | ||||||
</Fragment> | ||||||
)} | ||||||
</CommentCard> | ||||||
) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,19 +1,13 @@ | ||||||
import { useEffect, useState } from 'react' | ||||||
|
||||||
/* | ||||||
* A function that tells us when it's safe to start loading discussion | ||||||
* data from the aragon/api | ||||||
* */ | ||||||
|
||||||
export default () => { | ||||||
const [handshakeOccured, setHandshakeOccured] = useState(false) | ||||||
const sendMessageToWrapper = (name, value) => { | ||||||
window.parent.postMessage({ from: 'app', name, value }, '*') | ||||||
} | ||||||
const handleWrapperMessage = ({ data }) => { | ||||||
if (data.from !== 'wrapper') { | ||||||
return | ||||||
} | ||||||
if (data.name === 'ready') { | ||||||
sendMessageToWrapper('ready', true) | ||||||
setHandshakeOccured(true) | ||||||
} | ||||||
} | ||||||
const handleWrapperMessage = ({ data }) => setHandshakeOccured(true) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor misspelling
Suggested change
|
||||||
useEffect(() => { | ||||||
return window.addEventListener('message', handleWrapperMessage) | ||||||
}, []) | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,17 +3,19 @@ | |||||
"version": "1.0.0", | ||||||
"description": "", | ||||||
"dependencies": { | ||||||
"@aragon/api": "2.0.0-beta.8", | ||||||
"@aragon/api-react": "2.0.0-beta.6", | ||||||
"@aragon/ui": "1.0.0-alpha.11", | ||||||
"@babel/polyfill": "^7.2.5", | ||||||
"ipfs-http-client": "^32.0.1", | ||||||
"lodash.clonedeep": "^4.5.0", | ||||||
"react-markdown": "^4.1.0", | ||||||
"prop-types": "^15.7.2", | ||||||
"styled-components": "4.1.3" | ||||||
}, | ||||||
"peerDependencies": { | ||||||
"@aragon/api": "2.0.0-beta.8", | ||||||
"@aragon/api-react": "2.0.0-beta.6", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. api-react must be updated to at least beta.9 as well |
||||||
"@aragon/ui": "^1.0.0", | ||||||
"react": "^16.8.6", | ||||||
"react-dom": "^16.8.6", | ||||||
"react-markdown": "^4.1.0", | ||||||
"styled-components": "4.1.3", | ||||||
"ipfs-http-client": "^32.0.1", | ||||||
"lodash.clonedeep": "^4.5.0" | ||||||
"react-dom": "^16.8.6" | ||||||
}, | ||||||
"devDependencies": { | ||||||
"@babel/core": "^7.4.5", | ||||||
|
@@ -50,10 +52,10 @@ | |||||
"start:app": "cd app && npm start && cd ..", | ||||||
"test": "cross-env TRUFFLE_TEST=true npm run ganache-cli:test", | ||||||
"compile": "aragon contracts compile", | ||||||
"build": "npm run sync-assets && npm run build:app && npm run build:script", | ||||||
"build": "npm run compile && npm run sync-assets && npm run build:app && npm run build:script", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Compile step is probably not needed here, as it is part of the regular build during |
||||||
"build:app": "parcel build ./app/index.html -d dist/ --public-url \".\" --no-cache", | ||||||
"build:script": "parcel build ./app/script.js -d dist/ --no-cache", | ||||||
"publish:cd": "../../shared/deployments/check-publish.sh", | ||||||
"publish:cd": "yes | aragon apm publish major --files dist/ --environment continuous-deployment --apm.ipfs.rpc https://ipfs.autark.xyz:5001 --ipfs-check false --skip-confirmation true", | ||||||
"publish:http": "npm run build:script && yes | aragon apm publish major --files dist --http localhost:9999 --http-served-from ./dist --propagate-content false --skip-confirmation true", | ||||||
"publish:patch": "aragon apm publish patch", | ||||||
"publish:minor": "aragon apm publish minor", | ||||||
|
@@ -62,7 +64,8 @@ | |||||
"lint": "solium --dir ./contracts", | ||||||
"lint:fix": "eslint . --fix && solium --dir ./contracts --fix", | ||||||
"coverage": "cross-env SOLIDITY_COVERAGE=true npm run ganache-cli:test", | ||||||
"ganache-cli:test": "sh ./node_modules/@aragon/test-helpers/ganache-cli.sh" | ||||||
"ganache-cli:test": "sh ./node_modules/@aragon/test-helpers/ganache-cli.sh", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This script will probably be located at the root folder as long as we use the hoisted version for test-helpers
Suggested change
|
||||||
"frontend": "npm run sync-assets && parcel app/index.html --port 9999" | ||||||
}, | ||||||
"browserslist": [ | ||||||
"last 2 Chrome versions" | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could potentially result in multiple discussionIds assigned to the same appIdentifier, that could end up being a bit chaotic, how would we handle this potential issue?