JS: Converted/updated translation code to TS, fixed some comment counts
Some checks failed
lint-js / build (push) Has been cancelled
test-js / build (push) Has been cancelled

- 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:
Dan Brown
2024-10-07 22:55:10 +01:00
parent 8b9bcc1768
commit d22413b931
8 changed files with 152 additions and 146 deletions

View File

@ -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() {