From 450d74848ecdc4ad0046cb23bea29d0558587b95 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 20 Jan 2017 19:20:43 -0300 Subject: [PATCH] Notifications are back --- client/coral-embed-stream/src/Embed.js | 44 ++++++++++--------- .../src/graphql/mutations/index.js | 5 +-- .../modules/notification/Notification.js | 1 + client/coral-plugin-commentbox/CommentBox.js | 5 ++- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/client/coral-embed-stream/src/Embed.js b/client/coral-embed-stream/src/Embed.js index 746e7bd40..87da4271c 100644 --- a/client/coral-embed-stream/src/Embed.js +++ b/client/coral-embed-stream/src/Embed.js @@ -9,19 +9,19 @@ import {queryStream} from './graphql/queries' import { // itemActions, - // Notification, + Notification, notificationActions, authActions -} from '../../coral-framework'; +} from 'coral-framework'; import Stream from './Stream'; -import CommentBox from '../../coral-plugin-commentbox/CommentBox'; -import InfoBox from '../../coral-plugin-infobox/InfoBox'; +import CommentBox from 'coral-plugin-commentbox/CommentBox'; +import InfoBox from 'coral-plugin-infobox/InfoBox'; // import Content from '../../coral-plugin-commentcontent/CommentContent'; // import PubDate from '../../coral-plugin-pubdate/PubDate'; -import Count from '../../coral-plugin-comment-count/CommentCount'; +import Count from 'coral-plugin-comment-count/CommentCount'; // import AuthorName from '../../coral-plugin-author-name/AuthorName'; // import {ReplyBox, ReplyButton} from '../../coral-plugin-replies'; @@ -97,7 +97,7 @@ class Embed extends Component { } render () { - + console.log(this.props) // const rootItemId = this.props.items.assets && Object.keys(this.props.items.assets)[0]; // const rootItem = this.props.items.assets && this.props.items.assets[rootItemId]; // const {actions, users, comments} = this.props.items; @@ -156,11 +156,11 @@ class Embed extends Component { showSignInDialog={showSignInDialog}/> } - {/* */} + - {/* */} + } ; } } -const mapStateToProps = state => (state); +const mapStateToProps = state => ({ + config: state.config.toJS(), + items: state.items.toJS(), + notification: state.notification.toJS(), + auth: state.auth.toJS(), + userData: state.user.toJS() +}); const mapDispatchToProps = dispatch => ({ // addItem: (item, item_id) => dispatch(addItem(item, item_id)), // updateItem: (id, property, value, itemType) => dispatch(updateItem(id, property, value, itemType)), - // postItem: (data, type, id) => { - // console.log('postItem', dispatch, ownProps) - // // dispatch(postItem(data, type, id, ownProps)) - // }, // getStream: (rootId) => dispatch(getStream(rootId)), addNotification: (type, text) => dispatch(addNotification(type, text)), clearNotification: () => dispatch(clearNotification()), diff --git a/client/coral-embed-stream/src/graphql/mutations/index.js b/client/coral-embed-stream/src/graphql/mutations/index.js index 1c74d2e69..2ed814f7a 100644 --- a/client/coral-embed-stream/src/graphql/mutations/index.js +++ b/client/coral-embed-stream/src/graphql/mutations/index.js @@ -4,15 +4,12 @@ import POST_COMMENT from './postComment.graphql'; export const postComment = graphql(POST_COMMENT, { props: ({dispatch, mutate}) => ({ postItem: ({asset_id, body}) => { - mutate({ + return mutate({ variables: { asset_id, body, parent_id: null } - }).then(({data}) => { - console.log('it workt'); - console.log(data); }); }}), }); diff --git a/client/coral-framework/modules/notification/Notification.js b/client/coral-framework/modules/notification/Notification.js index 2a5e1d693..2d4d0ce91 100644 --- a/client/coral-framework/modules/notification/Notification.js +++ b/client/coral-framework/modules/notification/Notification.js @@ -1,6 +1,7 @@ import React from 'react'; const Notification = (props) => { + console.log(props) if (props.notification.text) { setTimeout(() => { props.clearNotification(); diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index fe67b22e0..52a6377fe 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -58,11 +58,12 @@ class CommentBox extends Component { return; } postItem(comment, 'comments') - .then((postedComment) => { + .then(({data}) => { + const postedComment = data.createComment const commentId = postedComment.id; if (postedComment.status === 'rejected') { addNotification('error', lang.t('comment-post-banned-word')); - } else if (premod === 'pre') { + } else if (postedComment.status === 'PREMOD') { addNotification('success', lang.t('comment-post-notif-premod')); } else { appendItemArray(parent_id || id, related, commentId, !parent_id, parent_type);