Comments
Extends:
API → Comments
Method Summary
Public Methods | ||
public |
Loads a proof's comments. |
Public Methods
public load(options: object | string): Promise<Array<Comment>> source
Loads a proof's comments.
Params:
Name | Type | Attribute | Description |
options | object | string | The options or proof id |
|
options.proofId | string | The proof id |
|
options.pageNumber | number |
|
The page number (if you only need a single page's comments) |
options.sinceDate | Date |
|
Return comments which have only been created since this date |
options.async | boolean |
|
Whether to decrypt the comments separately (must provide the |
options.decrypt | boolean |
|
Whether to decrypt the comments at all. Comment text will be unreadable if this option is disabled. The promise will immediately resolve once the comment metadata has been obtained. |
options.onDecryptComment | function |
|
Invoked every time a comment has finished decrypting |
Example:
const comments = await client.comments.load('PO1CD95SOTBJQ99A');
console.log(comments);
const comments = await client.comments.load({
proofId: 'PO1CD95SOTBJQ99A',
pageNumber: 7,
});
console.log(comments); // [Comment, Comment, Comment, ...]
class CommentsList extends React.Component {
state = {
comments: [],
};
componentWillMount() {
const comments = await client.comments.load({
proofId: 'PO1CD95SOTBJQ99A',
async: true,
onDecryptComment(comment) {
console.log(`Comment ${comment.id} has been decrypted, updating bindings...`);
this.forceUpdate(); // tell React to re-render
}
});
this.setState({ comments });
}
render() {
return (
<ul>
{this.state.comments.map(comment => (
<li key={comment.id}>
<strong>{comment.user.email}</strong><br />
{comment.html
? <div dangerouslySetInnerHTML={{__html: comment.html}} />
: <div>Loading...</div>}
</li>
))}
</ul>
);
}
}