]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/page-comments.js
API: Added test to cover system info endpoint
[bookstack] / resources / js / components / page-comments.js
index cfb0634a904c3500a58ce6bc017f355d57f3d75a..8f023836b090876360c120df95e3c1f0a137bf18 100644 (file)
@@ -1,6 +1,6 @@
 import {Component} from './component';
-import {getLoading, htmlToDom} from '../services/dom';
-import {buildForInput} from '../wysiwyg/config';
+import {getLoading, htmlToDom} from '../services/dom.ts';
+import {buildForInput} from '../wysiwyg-tinymce/config';
 
 export class PageComments extends Component {
 
@@ -40,7 +40,7 @@ export class PageComments extends Component {
 
     setupListeners() {
         this.elem.addEventListener('page-comment-delete', () => {
-            this.updateCount();
+            setTimeout(() => this.updateCount(), 1);
             this.hideForm();
         });
 
@@ -72,7 +72,13 @@ export class PageComments extends Component {
 
         window.$http.post(`/comment/${this.pageId}`, reqData).then(resp => {
             const newElem = htmlToDom(resp.data);
-            this.formContainer.after(newElem);
+
+            if (reqData.parent_id) {
+                this.formContainer.after(newElem);
+            } else {
+                this.container.append(newElem);
+            }
+
             window.$events.success(this.createdText);
             this.hideForm();
             this.updateCount();
@@ -87,7 +93,7 @@ export class PageComments extends Component {
 
     updateCount() {
         const count = this.getCommentCount();
-        this.commentsTitle.textContent = window.trans_plural(this.countText, count, {count});
+        this.commentsTitle.textContent = window.$trans.choice(this.countText, count, {count});
     }
 
     resetForm() {