From c3a89511c0dc27f69f57130c90e7cafe1ad0c230 Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Wed, 17 Apr 2024 22:46:21 +0300
Subject: [PATCH] remove comment from map and context

---
 .../src/CommentsService/CommentsService.js          |  3 ++-
 .../src/CommentsService/components/RightArea.js     | 13 ++++++++++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/wax-prosemirror-services/src/CommentsService/CommentsService.js b/wax-prosemirror-services/src/CommentsService/CommentsService.js
index 743685641..ea97c9596 100644
--- a/wax-prosemirror-services/src/CommentsService/CommentsService.js
+++ b/wax-prosemirror-services/src/CommentsService/CommentsService.js
@@ -48,7 +48,7 @@ export default class CommentsService extends Service {
         this.allCommentsFromStates = this.allCommentsFromStates.concat([
           ...items,
         ]);
-        commentsConfig.getComments(this.allCommentsFromStates);
+
         if (this.app.context.options.resolvedComment) {
           this.allCommentsFromStates = this.allCommentsFromStates.filter(
             comm => {
@@ -56,6 +56,7 @@ export default class CommentsService extends Service {
             },
           );
         }
+        commentsConfig.getComments(this.allCommentsFromStates);
         this.app.context.setOption({ comments: this.allCommentsFromStates });
       },
     };
diff --git a/wax-prosemirror-services/src/CommentsService/components/RightArea.js b/wax-prosemirror-services/src/CommentsService/components/RightArea.js
index 8ce766e6a..923525246 100644
--- a/wax-prosemirror-services/src/CommentsService/components/RightArea.js
+++ b/wax-prosemirror-services/src/CommentsService/components/RightArea.js
@@ -5,6 +5,7 @@ import useDeepCompareEffect from 'use-deep-compare-effect';
 import { each, uniqBy, sortBy, groupBy } from 'lodash';
 import { WaxContext, DocumentHelpers } from 'wax-prosemirror-core';
 import BoxList from './BoxList';
+import { CommentDecorationPluginKey } from '../plugins/CommentDecorationPlugin';
 
 export default ({ area, users }) => {
   const context = useContext(WaxContext);
@@ -80,12 +81,22 @@ export default ({ area, users }) => {
             WaxSurface.top +
             parseInt(WaxSurfaceMarginTop.slice(0, -2), 10);
         } else {
-          // comment is deleted
+          // comment is deleted from editing surface
+          context.setOption({ resolvedComment: id });
           context.setOption({
             comments: comments.filter(comment => {
               return comment.id !== id;
             }),
           });
+
+          setTimeout(() => {
+            activeView.dispatch(
+              activeView.state.tr.setMeta(CommentDecorationPluginKey, {
+                type: 'deleteComment',
+                id,
+              }),
+            );
+          });
         }
       } else {
         // Notes
-- 
GitLab