@@ -117,7 +130,7 @@ class Comment extends React.Component {
flag={flag}
id={comment.id}
author_id={comment.user.id}
- postAction={postAction}
+ postFlag={postFlag}
deleteAction={deleteAction}
showSignInDialog={showSignInDialog}
currentUser={currentUser} />
@@ -150,7 +163,8 @@ class Comment extends React.Component {
depth={depth + 1}
asset={asset}
currentUser={currentUser}
- postAction={postAction}
+ postLike={postLike}
+ postFlag={postFlag}
deleteAction={deleteAction}
showSignInDialog={showSignInDialog}
reactKey={reply.id}
@@ -158,7 +172,6 @@ class Comment extends React.Component {
comment={reply} />;
})
}
-
);
}
diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js
index 2def22ce8..236e677e8 100644
--- a/client/coral-embed-stream/src/Embed.js
+++ b/client/coral-embed-stream/src/Embed.js
@@ -10,7 +10,7 @@ const {addNotification, clearNotification} = notificationActions;
const {fetchAssetSuccess} = assetActions;
import {queryStream} from 'coral-framework/graphql/queries';
-import {postComment, postAction, deleteAction} from 'coral-framework/graphql/mutations';
+import {postComment, postFlag, postLike, deleteAction} from 'coral-framework/graphql/mutations';
import {editName} from 'coral-framework/actions/user';
import {Notification, notificationActions, authActions, assetActions, pym} from 'coral-framework';
@@ -92,7 +92,7 @@ class Embed extends Component {
minHeight: document.body.scrollHeight + 200
} : {};
- if (loading) {
+ if (loading || !asset) {
return
@@ -150,15 +151,15 @@ class FlagButton extends Component {
}
{
this.state.reason &&
-
}
diff --git a/client/coral-plugin-likes/LikeButton.js b/client/coral-plugin-likes/LikeButton.js
index 8d497bcef..9b3abfb00 100644
--- a/client/coral-plugin-likes/LikeButton.js
+++ b/client/coral-plugin-likes/LikeButton.js
@@ -12,7 +12,7 @@ class LikeButton extends Component {
count: PropTypes.number
}),
id: PropTypes.string,
- postAction: PropTypes.func.isRequired,
+ postLike: PropTypes.func.isRequired,
deleteAction: PropTypes.func.isRequired,
showSignInDialog: PropTypes.func.isRequired,
currentUser: PropTypes.shape({
@@ -26,9 +26,9 @@ class LikeButton extends Component {
}
render() {
- const {like, id, postAction, deleteAction, showSignInDialog, currentUser} = this.props;
+ const {like, id, postLike, deleteAction, showSignInDialog, currentUser} = this.props;
const {localPost, localDelete} = this.state;
- const liked = (like && like.current && !localDelete) || localPost;
+ const liked = (like && like.current_user && !localDelete) || localPost;
let count = like ? like.count : 0;
if (localPost) {count += 1;}
if (localDelete) {count -= 1;}
@@ -42,28 +42,23 @@ class LikeButton extends Component {
if (currentUser.banned) {
return;
}
- if (!liked) {
- this.setState({localPost: 'temp', localDelete: false});
- postAction({
+ if (!liked) { // this comment has not yet been liked by this user.
+ this.setState({localPost: 'temp'});
+ postLike({
item_id: id,
- item_type: 'COMMENTS',
- action_type: 'LIKE'
+ item_type: 'COMMENTS'
}).then(({data}) => {
- this.setState({localPost: data.createAction.id});
+ this.setState({localPost: data.createLike.like.id});
});
} else {
this.setState((prev) => prev.localPost ? {...prev, localPost: null} : {...prev, localDelete: true});
- deleteAction(localPost || like.current.id);
+ deleteAction(localPost || like.current_user.id);
}
};
return