mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-19 19:51:21 +08:00
JS: Converted/updated translation code to TS, fixed some comment counts
- Migrated translation service to TS, stripping a lot of now unused code along the way. - Added test to cover translation service. - Fixed some comment count issues, where it was not showing correct value. or updating, on comment create or delete.
This commit is contained in:
@ -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,8 @@ export class PageComments extends Component {
|
||||
|
||||
updateCount() {
|
||||
const count = this.getCommentCount();
|
||||
this.commentsTitle.textContent = window.trans_plural(this.countText, count, {count});
|
||||
console.log('update count', count, this.container);
|
||||
this.commentsTitle.textContent = window.$trans.choice(this.countText, count, {count});
|
||||
}
|
||||
|
||||
resetForm() {
|
||||
|
Reference in New Issue
Block a user