From 1bca2a96e562a649e75c9c9d820ac66da9d43756 Mon Sep 17 00:00:00 2001 From: okbel Date: Thu, 22 Feb 2018 11:46:10 -0300 Subject: [PATCH] Updating the store - Fully Working :tada: --- client/coral-framework/graphql/mutations.js | 28 +++++++++++++++++++ .../client/components/CommentContent.js | 5 ++++ .../client/components/Editor.js | 2 +- .../client/containers/CommentContent.js | 1 + 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/client/coral-framework/graphql/mutations.js b/client/coral-framework/graphql/mutations.js index f34a2cc88..ffa139abc 100644 --- a/client/coral-framework/graphql/mutations.js +++ b/client/coral-framework/graphql/mutations.js @@ -1,5 +1,6 @@ import { gql } from 'react-apollo'; import withMutation from '../hocs/withMutation'; +import update from 'immutability-helper'; function convertItemType(item_type) { switch (item_type) { @@ -458,6 +459,33 @@ export const withEditComment = withMutation( asset_id, edit, }, + update: proxy => { + const editCommentFragment = gql` + fragment Talk_EditComment on Comment { + body + htmlBody + } + `; + + const fragmentId = `Comment_${id}`; + + const data = proxy.readFragment({ + fragment: editCommentFragment, + id: fragmentId, + }); + + const updated = update(data, { + htmlBody: { + $set: edit.htmlBody, + }, + }); + + proxy.writeFragment({ + fragment: editCommentFragment, + id: fragmentId, + data: updated, + }); + }, }); }, }), diff --git a/plugins/talk-plugin-comment-content/client/components/CommentContent.js b/plugins/talk-plugin-comment-content/client/components/CommentContent.js index f21c888b7..de2b89339 100644 --- a/plugins/talk-plugin-comment-content/client/components/CommentContent.js +++ b/plugins/talk-plugin-comment-content/client/components/CommentContent.js @@ -1,4 +1,5 @@ import React from 'react'; +import PropTypes from 'prop-types'; import Linkify from 'react-linkify'; const name = 'talk-plugin-comment-content'; @@ -21,4 +22,8 @@ const CommentContent = ({ comment }) => { ); }; +CommentContent.propTypes = { + comment: PropTypes.object.isRequired, +}; + export default CommentContent; diff --git a/plugins/talk-plugin-rte/client/components/Editor.js b/plugins/talk-plugin-rte/client/components/Editor.js index a6bc4240a..c921c846c 100644 --- a/plugins/talk-plugin-rte/client/components/Editor.js +++ b/plugins/talk-plugin-rte/client/components/Editor.js @@ -45,7 +45,7 @@ class Editor extends React.Component { render() { const { id, classNames } = this.props; - console.log(this.props); + return (