From ba754886d432ceeec9f3a3d02acd2126bf269624 Mon Sep 17 00:00:00 2001 From: Giannis Kopanas <jkopanas@gmail.com> Date: Tue, 12 Dec 2023 12:22:16 +0000 Subject: [PATCH] fix(services): comment fix username --- editors/demo/src/Editoria/layout/EditoriaLayout.js | 6 ++++++ .../src/CommentsService/components/ConnectedComment.js | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/editors/demo/src/Editoria/layout/EditoriaLayout.js b/editors/demo/src/Editoria/layout/EditoriaLayout.js index 68b7e97be..912187816 100644 --- a/editors/demo/src/Editoria/layout/EditoriaLayout.js +++ b/editors/demo/src/Editoria/layout/EditoriaLayout.js @@ -257,6 +257,12 @@ const EditoriaLayout = ({ editor }) => { useEffect(() => {}, [delayedShowedNotes]); + // const users = [{ + // userId: '1', + // displayName: 'test test', + // currentUser: true, + // }] + return ( <ThemeProvider theme={cokoTheme}> <Wrapper style={fullScreenStyles} id="wax-container"> diff --git a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js index 5a7b1cdc5..e9fad52a9 100644 --- a/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js +++ b/wax-prosemirror-services/src/CommentsService/components/ConnectedComment.js @@ -132,9 +132,14 @@ export default ({ comment, top, commentId, recalculateTops, users }) => { const onClickPost = ({ commentValue, title }) => { setClickPost(true); + const currentUser = user || (users || []).find(u => u.currentUser === true); + const obj = { content: commentValue, - displayName: user.username, + displayName: currentUser + ? currentUser.displayName || currentUser.username + : 'Anonymous', + userId: currentUser ? currentUser.userId : '1', timestamp: Math.floor(Date.now()), }; -- GitLab