fixes+improvements

This commit is contained in:
2021-10-03 20:22:58 +02:00
parent 7477527f24
commit a94647d549
10 changed files with 190 additions and 49 deletions
+4 -2
View File
@@ -4,7 +4,9 @@
<p>{{entry.text}}</p>
<ui-commentform [target]="entry.id" [change]="boundRefresh"></ui-commentform>
<ui-commentform [target]="entry.id" [change]="boundReplyCallback"></ui-commentform>
<ui-comments [target]="entry.id"></ui-comments>
<ng-container *ngIf="entry.metadata.comments">
<ui-comments [target]="entry.id"></ui-comments>
</ng-container>
</ng-container>
+12 -1
View File
@@ -3,6 +3,7 @@ import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { EntriesService } from '../../services/entries.service';
import { CommentService } from '../../services/comment.service';
@Component({
selector: 'page-entry',
@@ -14,13 +15,15 @@ export class PageEntry implements OnInit {
entry: any;
notfound: boolean = false;
boundRefresh: Function;
boundReplyCallback: Function;
constructor(private entriesService: EntriesService,
constructor(private commentService: CommentService, private entriesService: EntriesService,
private route: ActivatedRoute) { }
ngOnInit(): void {
this.id = +this.route.snapshot.paramMap.get('id');
this.boundRefresh = this.refresh.bind(this);
this.boundReplyCallback = this.replyCallback.bind(this);
this.refresh();
}
@@ -34,4 +37,12 @@ export class PageEntry implements OnInit {
})
}
replyCallback(): void {
this.entry.metadata.reply = false;
this.entry.metadata.comments = 0;
this.commentService.count(this.entry.id).subscribe((data) => {
this.entry.metadata.comments = +data;
});
}
}