mirror of
https://github.com/wassname/talk.git
synced 2026-08-12 12:30:39 +08:00
Updating commentstream to reflect new store structure.
This commit is contained in:
@@ -30,11 +30,11 @@ const {setLoggedInUser} = authActions
|
||||
},
|
||||
(dispatch) => {
|
||||
return {
|
||||
addItem: (item) => {
|
||||
return dispatch(addItem(item))
|
||||
addItem: (item, itemType) => {
|
||||
return dispatch(addItem(item, itemType))
|
||||
},
|
||||
updateItem: (id, property, value) => {
|
||||
return dispatch(updateItem(id, property, value))
|
||||
updateItem: (id, property, value, itemType) => {
|
||||
return dispatch(updateItem(id, property, value, itemType))
|
||||
},
|
||||
postItem: (data, type, id) => {
|
||||
return dispatch(postItem(data, type, id))
|
||||
@@ -54,8 +54,8 @@ const {setLoggedInUser} = authActions
|
||||
postAction: (item, action, user) => {
|
||||
return dispatch(postAction(item, action, user))
|
||||
},
|
||||
appendItemArray: (item, property, value, addToFront) => {
|
||||
return dispatch(appendItemArray(item, property, value, addToFront))
|
||||
appendItemArray: (item, property, value, addToFront, itemType) => {
|
||||
return dispatch(appendItemArray(item, property, value, addToFront, itemType))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -97,7 +97,7 @@ class CommentStream extends Component {
|
||||
|
||||
|
||||
const rootItemId = 'assetTest'
|
||||
const rootItem = this.props.items[rootItemId]
|
||||
const rootItem = this.props.items.assets && this.props.items.assets[rootItemId]
|
||||
return <div>
|
||||
{
|
||||
rootItem ?
|
||||
@@ -116,7 +116,7 @@ class CommentStream extends Component {
|
||||
</div>
|
||||
{
|
||||
rootItem.comments.map((commentId) => {
|
||||
const comment = this.props.items[commentId]
|
||||
const comment = this.props.items.comments[commentId]
|
||||
return <div className="comment" key={commentId}>
|
||||
<hr aria-hidden={true}/>
|
||||
<AuthorName name={comment.username}/>
|
||||
@@ -144,7 +144,7 @@ class CommentStream extends Component {
|
||||
{
|
||||
comment.children &&
|
||||
comment.children.map((replyId) => {
|
||||
let reply = this.props.items[replyId]
|
||||
let reply = this.props.items.comments[replyId]
|
||||
return <div className="reply" key={replyId}>
|
||||
<hr aria-hidden={true}/>
|
||||
<AuthorName name={reply.username}/>
|
||||
|
||||
@@ -25,17 +25,20 @@ class CommentBox extends Component {
|
||||
asset_id: id,
|
||||
username: this.state.username
|
||||
}
|
||||
let related
|
||||
let related;
|
||||
let parent_type;
|
||||
if (parent_id) {
|
||||
comment.parent_id = parent_id
|
||||
related = 'children'
|
||||
parent_type = 'comments'
|
||||
} else {
|
||||
related = 'comments'
|
||||
parent_type = 'assets'
|
||||
}
|
||||
updateItem(parent_id, 'showReply', false)
|
||||
updateItem(parent_id, 'showReply', false, 'comments')
|
||||
postItem(comment, 'comments')
|
||||
.then((comment_id) => {
|
||||
appendItemArray(parent_id || id, related, comment_id, parent_id ? false : true)
|
||||
appendItemArray(parent_id || id, related, comment_id, parent_id ? false : true, parent_type)
|
||||
addNotification('success', 'Your comment has been posted.')
|
||||
}).catch((err) => console.error(err))
|
||||
this.setState({body: ''})
|
||||
|
||||
@@ -5,7 +5,7 @@ const name = 'coral-plugin-replies'
|
||||
|
||||
const ReplyButton = (props) => <button
|
||||
className={name + '-reply-button'}
|
||||
onClick={(e) => props.updateItem(props.id || props.parent_id, 'showReply', true)}>
|
||||
onClick={(e) => props.updateItem(props.id || props.parent_id, 'showReply', true, 'comments')}>
|
||||
<i className={name + '-icon material-icons'}
|
||||
aria-hidden={true}>reply</i>
|
||||
{lang.t('reply')}
|
||||
|
||||
Reference in New Issue
Block a user