Skip to content
Snippets Groups Projects
Commit 8bb4d5e1 authored by Christos's avatar Christos
Browse files

Merge branch 'standard-comments' into 'master'

Standard comments

See merge request !611
parents 1acc0f87 7eba8dc1
No related branches found
No related tags found
1 merge request!611Standard comments
Pipeline #61996 passed with stages
in 3 minutes and 32 seconds
......@@ -177,14 +177,26 @@ export default ({ area, users }) => {
};
useDeepCompareEffect(() => {
setMarksNodes(
updateMarks(
pmViews,
CommentDecorationPluginKey?.getState(
activeView.state,
)?.allCommentsDataList(),
),
);
if (app.config.get('config.YjsService')) {
setMarksNodes(
updateMarks(
pmViews,
CommentDecorationPluginKey?.getState(
activeView.state,
)?.allCommentsDataList(),
),
);
} else {
setMarksNodes(
updateMarks(
pmViews,
CommentDecorationPluginKey?.getState(
activeView.state,
)?.allCommentsList(),
),
);
}
let firstRunTimeout = () => true;
if (isFirstRun) {
firstRunTimeout = setTimeout(() => {
......
......@@ -7,7 +7,6 @@ import { CommentDecorationPluginKey } from './CommentDecorationPlugin';
const commentPlugin = new PluginKey('commentPlugin');
const getComment = (state, app) => {
if (!app.config.get('config.YjsService')) return getCommentNonYjs(state, app);
const { context } = app;
const commentsMap = CommentDecorationPluginKey.getState(state).getMap();
const commentsDataMap = CommentDecorationPluginKey.getState(
......@@ -24,6 +23,10 @@ const getComment = (state, app) => {
}
});
if (!app.config.get('config.YjsService')) {
return getCommentNonYjs(commentData, state, context);
}
commentData = sortBy(commentData, ['data.pmFrom']);
if (commentData.length > 0) {
......@@ -44,8 +47,23 @@ const getComment = (state, app) => {
return undefined;
};
const getCommentNonYjs = (state, app) => {
console.log('non yjs active');
const getCommentNonYjs = (comments, state, context) => {
const commentData = sortBy(comments, ['from']);
if (commentData.length > 0) {
if (
(state.selection.from !== state.selection.to &&
last(commentData)?.data?.conversation.length === 0) ||
(state.selection.from === state.selection.to &&
last(commentData)?.data?.conversation.length !== 0)
) {
context.setOption({ activeComment: last(commentData) });
return last(commentData);
}
return undefined;
}
return undefined;
};
export default (key, app) => {
......
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