Skip to content
Snippets Groups Projects
Commit 5f81ee79 authored by Tom Käsler's avatar Tom Käsler
Browse files

Use count API endpoint for comments

Based on arsnova-comment-service commit
  b88aa32c54ba773373b817d36313787ae895e809
parent 07005498
1 merge request!268Room page comment counter
Pipeline #27652 passed with stages
in 7 minutes and 16 seconds
......@@ -35,9 +35,9 @@ export class RoomPageComponent implements OnInit {
this.roomService.getRoomByShortId(id).subscribe(room => {
this.room = room;
this.isLoading = false;
this.commentService.getComments(this.room.id)
.subscribe(comments => {
this.commentCounter = comments.length;
this.commentService.countByRoomId(this.room.id)
.subscribe(commentCounter => {
this.commentCounter = commentCounter;
});
this.wsCommentService.getCommentStream(this.room.id).subscribe((message: Message) => {
const msg = JSON.parse(message.body);
......
......@@ -14,7 +14,8 @@ export class CommentService extends BaseHttpService {
private apiUrl = {
base: '/api',
comment: '/comment',
find: '/find'
find: '/find',
count: '/count'
};
constructor(private http: HttpClient) {
......@@ -74,4 +75,15 @@ export class CommentService extends BaseHttpService {
catchError(this.handleError<Comment>('deleteComment'))
);
}
countByRoomId(roomId: string): Observable<number> {
const connectionUrl = this.apiUrl.base + this.apiUrl.comment + this.apiUrl.find + this.apiUrl.count;
return this.http.post<number>(connectionUrl, {
properties: { roomId: roomId },
externalFilters: {}
}, httpOptions).pipe(
tap(_ => ''),
catchError(this.handleError<number>('countByRoomId', 0))
);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment