]> BookStack Code Mirror - bookstack/blobdiff - resources/js/components/page-comment.ts
Comments: Further range of content reference ux improvements
[bookstack] / resources / js / components / page-comment.ts
index d2cbd21d1db89810fbd95255b8efd78b6ee3f9fa..ce35cdc4a243e90e058217f5c45178b037dd3e1e 100644 (file)
@@ -1,6 +1,7 @@
 import {Component} from './component';
 import {getLoading, htmlToDom} from '../services/dom.ts';
 import {buildForInput} from '../wysiwyg-tinymce/config';
+import {PageCommentReference} from "./page-comment-reference";
 
 export class PageComment extends Component {
 
@@ -130,17 +131,34 @@ export class PageComment extends Component {
 
         await window.$http.delete(`/comment/${this.commentId}`);
         this.$emit('delete');
-        this.container.closest('.comment-branch')?.remove();
+
+        const branch = this.container.closest('.comment-branch');
+        if (branch instanceof HTMLElement) {
+            const refs = window.$components.allWithinElement<PageCommentReference>(branch, 'page-comment-reference');
+            for (const ref of refs) {
+                ref.hideMarker();
+            }
+            branch.remove();
+        }
+
         window.$events.success(this.deletedText);
     }
 
     protected async archive(): Promise<void> {
         this.showLoading();
         const isArchived = this.archiveButton.dataset.isArchived === 'true';
+        const action = isArchived ? 'unarchive' : 'archive';
 
-        await window.$http.put(`/comment/${this.commentId}/${isArchived ? 'unarchive' : 'archive'}`);
-        this.$emit('archive');
+        const response = await window.$http.put(`/comment/${this.commentId}/${action}`);
         window.$events.success(this.archiveText);
+        this.$emit(action, {new_thread_dom: htmlToDom(response.data as string)});
+
+        const branch = this.container.closest('.comment-branch') as HTMLElement;
+        const references = window.$components.allWithinElement<PageCommentReference>(branch, 'page-comment-reference');
+        for (const reference of references) {
+            reference.hideMarker();
+        }
+        branch.remove();
     }
 
     protected showLoading(): HTMLElement {