mirror of
https://github.com/wassname/talk.git
synced 2026-07-16 11:22:16 +08:00
Updating the store - Fully Working 🎉
This commit is contained in:
@@ -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
|
||||
}
|
||||
`,
|
||||
|
||||
Reference in New Issue
Block a user