From 7507309e326f50078cdbad3e14fb746839c9903a Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Mon, 20 Feb 2017 15:32:28 +0200
Subject: [PATCH] rerender comments on change

---
 app/components/SimpleEditor/Editor.js                  |  5 -----
 .../SimpleEditor/elements/comment/CommentComponent.js  |  3 +++
 .../SimpleEditor/panes/Comments/CommentsProvider.js    | 10 ++++------
 3 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/app/components/SimpleEditor/Editor.js b/app/components/SimpleEditor/Editor.js
index 62b8586..df2376b 100644
--- a/app/components/SimpleEditor/Editor.js
+++ b/app/components/SimpleEditor/Editor.js
@@ -43,16 +43,11 @@ class Editor extends ProseEditor {
   willUpdateState () {}
 
   didMount () {
-    this.editorSession.onRender('document', this.editorContentUpdated, this)
     // this.documentSession.on('didUpdate', this.documentSessionUpdated, this)
     // this.documentSession.on('fileUploadTrigger', this.handleUpload, this)
     this.extendState({ editorReady: true })
   }
 
-  editorContentUpdated () {
-    this.emit('ui:updated')
-  }
-
   handleUpload (file, callback) {
     const { fileUpload } = this.props
 
diff --git a/app/components/SimpleEditor/elements/comment/CommentComponent.js b/app/components/SimpleEditor/elements/comment/CommentComponent.js
index 8eb1887..c6e8998 100644
--- a/app/components/SimpleEditor/elements/comment/CommentComponent.js
+++ b/app/components/SimpleEditor/elements/comment/CommentComponent.js
@@ -4,6 +4,8 @@ class CommentComponent extends AnnotationComponent {
   constructor (parent, props) {
     super(parent, props)
     this.active = props.node.active
+
+    // this.context.editorSession.onUpdate('', this.rerender, this)
   }
 
   render ($$) {
@@ -39,6 +41,7 @@ class CommentComponent extends AnnotationComponent {
   // put here all conditions for the node to change
   hasNodeChanged () {
     const { node } = this.props
+    console.log(node)
     if (this.active !== node.active) return true
     return false
   }
diff --git a/app/components/SimpleEditor/panes/Comments/CommentsProvider.js b/app/components/SimpleEditor/panes/Comments/CommentsProvider.js
index 24cbcb4..b6fc77c 100644
--- a/app/components/SimpleEditor/panes/Comments/CommentsProvider.js
+++ b/app/components/SimpleEditor/panes/Comments/CommentsProvider.js
@@ -1,5 +1,5 @@
 import _ from 'lodash'
-import { createAnnotation, TOCProvider as TocProvider } from 'substance'
+import { TOCProvider as TocProvider } from 'substance'
 
 class CommentsProvider extends TocProvider {
   // TODO -- works if I rename to doc
@@ -9,15 +9,13 @@ class CommentsProvider extends TocProvider {
     const editorSession = props.editorSession
 
     editorSession.onUpdate('', this.updateActiveEntry, this)
-
     editorSession.onRender('document', this.update, this)
 
-    // TODO is this needed?
+    // TODO is this needed anymore?
     // const doc = editorSession.getDocument()
     // doc.on('document:changed', this.update, this)
-
-    const editor = props.controller
-    editor.on('ui:updated', this.onUiUpdate, this)
+    // const editor = props.controller
+    // editor.on('ui:updated', this.onUiUpdate, this)
   }
 
   //
-- 
GitLab