Skip to content
Snippets Groups Projects
Commit 16206d3e authored by chris's avatar chris
Browse files

fix new comment

parent 9c223492
No related branches found
No related tags found
1 merge request!527fix title track
...@@ -72,16 +72,69 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { ...@@ -72,16 +72,69 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
} }
}, [activeComment]); }, [activeComment]);
// const onClickPost = ({ commentValue, title }) => {
// setClickPost(true);
// const currentUser = user || (users || []).find(u => u.currentUser === true);
// const obj = {
// content: commentValue,
// displayName: currentUser
// ? currentUser.displayName || currentUser.username
// : 'Anonymous',
// userId: currentUser ? currentUser.userId : '1',
// timestamp: Math.floor(Date.now()),
// };
// comment.attrs.title = title || comment.attrs.title;
// comment.attrs.conversation.push(obj);
// const id = uuidv4();
// allCommentsWithSameId.forEach(singleComment => {
// activeView.dispatch(
// activeView.state.tr.removeMark(
// singleComment.pos,
// singleComment.pos + singleComment.node.nodeSize,
// commentMark,
// ),
// );
// if (activeViewId !== 'main') {
// activeView.dispatch(
// activeView.state.tr
// .addMark(
// singleComment.pos,
// singleComment.pos + singleComment.node.nodeSize,
// commentMark.create({
// id,
// group: comment.attrs.group,
// viewid: comment.attrs.viewid,
// conversation: comment.attrs.conversation,
// title: comment.attrs.title,
// }),
// )
// .setMeta('forceUpdate', true),
// );
// }
// });
// if (activeViewId === 'main') {
// Commands.createComment(
// pmViews.main.state,
// pmViews.main.dispatch,
// comment.attrs.group,
// comment.attrs.viewid,
// comment.attrs.conversation,
// );
// }
// activeView.focus();
// recalculateTops();
// };
const onClickPost = ({ commentValue, title }) => { const onClickPost = ({ commentValue, title }) => {
setClickPost(true); setClickPost(true);
const currentUser = user || (users || []).find(u => u.currentUser === true);
const obj = { const obj = {
content: commentValue, content: commentValue,
displayName: currentUser displayName: user.username,
? currentUser.displayName || currentUser.username
: 'Anonymous',
userId: currentUser ? currentUser.userId : '1',
timestamp: Math.floor(Date.now()), timestamp: Math.floor(Date.now()),
}; };
...@@ -98,34 +151,22 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { ...@@ -98,34 +151,22 @@ export default ({ comment, top, commentId, recalculateTops, users }) => {
), ),
); );
if (activeViewId !== 'main') { activeView.dispatch(
activeView.dispatch( activeView.state.tr
activeView.state.tr .addMark(
.addMark( singleComment.pos,
singleComment.pos, singleComment.pos + singleComment.node.nodeSize,
singleComment.pos + singleComment.node.nodeSize, commentMark.create({
commentMark.create({ id,
id, group: comment.attrs.group,
group: comment.attrs.group, viewid: comment.attrs.viewid,
viewid: comment.attrs.viewid, conversation: comment.attrs.conversation,
conversation: comment.attrs.conversation, title: comment.attrs.title,
title: comment.attrs.title, }),
}), )
) .setMeta('forceUpdate', true),
.setMeta('forceUpdate', true),
);
}
});
if (activeViewId === 'main') {
Commands.createComment(
pmViews.main.state,
pmViews.main.dispatch,
comment.attrs.group,
comment.attrs.viewid,
comment.attrs.conversation,
); );
} });
activeView.focus(); activeView.focus();
recalculateTops(); recalculateTops();
}; };
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment