Updating the store - Fully Working 🎉

This commit is contained in:
okbel
2018-02-22 11:46:10 -03:00
parent 2f4c084811
commit 1bca2a96e5
4 changed files with 35 additions and 1 deletions
@@ -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,
});
},
});
},
}),
@@ -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;
@@ -45,7 +45,7 @@ class Editor extends React.Component {
render() {
const { id, classNames } = this.props;
console.log(this.props);
return (
<div
id={id}
@@ -5,6 +5,7 @@ import CommentContent from '../components/CommentContent';
export default withFragments({
comment: gql`
fragment TalkPluginRTE_CommentContent_comment on Comment {
body
htmlBody
}
`,