]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/comment/video-comment.service.ts
Improve comment tree UI
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.service.ts
index b8e5878c5b9c8391dedd419b70984e5eb5d222b6..550d42fa86552c65a2b100ff8691a6b4a26c2f14 100644 (file)
@@ -48,26 +48,31 @@ export class VideoCommentService {
                )
   }
 
-  getVideoCommentThreads (
+  getVideoCommentThreads (parameters: {
     videoId: number | string,
     componentPagination: ComponentPagination,
     sort: VideoSortField
-  ): Observable<{ comments: VideoComment[], totalComments: number}> {
+  }): Observable<ResultList<VideoComment>> {
+    const { videoId, componentPagination, sort } = parameters
+
     const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
 
     let params = new HttpParams()
     params = this.restService.addRestGetParams(params, pagination, sort)
 
     const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads'
-    return this.authHttp
-               .get(url, { params })
+    return this.authHttp.get<ResultList<VideoComment>>(url, { params })
                .pipe(
-                 map(this.extractVideoComments),
+                 map(result => this.extractVideoComments(result)),
                  catchError(err => this.restExtractor.handleError(err))
                )
   }
 
-  getVideoThreadComments (videoId: number | string, threadId: number): Observable<VideoCommentThreadTree> {
+  getVideoThreadComments (parameters: {
+    videoId: number | string,
+    threadId: number
+  }): Observable<VideoCommentThreadTree> {
+    const { videoId, threadId } = parameters
     const url = `${VideoCommentService.BASE_VIDEO_URL + videoId}/comment-threads/${threadId}`
 
     return this.authHttp
@@ -130,7 +135,7 @@ export class VideoCommentService {
       comments.push(new VideoComment(videoCommentJson))
     }
 
-    return { comments, totalComments }
+    return { data: comments, total: totalComments }
   }
 
   private extractVideoCommentTree (tree: VideoCommentThreadTree) {