import {
FeedFormat,
ResultList,
+ ThreadsResultList,
VideoComment as VideoCommentServerModel,
VideoCommentAdmin,
VideoCommentCreate,
videoId: number | string,
componentPagination: ComponentPaginationLight,
sort: string
- }): Observable<ResultList<VideoComment>> {
+ }): Observable<ThreadsResultList<VideoComment>> {
const { videoId, componentPagination, sort } = parameters
const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
params = this.restService.addRestGetParams(params, pagination, sort)
const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads'
- return this.authHttp.get<ResultList<VideoComment>>(url, { params })
+ return this.authHttp.get<ThreadsResultList<VideoComment>>(url, { params })
.pipe(
map(result => this.extractVideoComments(result)),
catchError(err => this.restExtractor.handleError(err))
return new VideoComment(videoComment)
}
- private extractVideoComments (result: ResultList<VideoCommentServerModel>) {
+ private extractVideoComments (result: ThreadsResultList<VideoCommentServerModel>) {
const videoCommentsJson = result.data
const totalComments = result.total
const comments: VideoComment[] = []
comments.push(new VideoComment(videoCommentJson))
}
- return { data: comments, total: totalComments }
+ return { data: comments, total: totalComments, totalNotDeletedComments: result.totalNotDeletedComments }
}
- private extractVideoCommentTree (tree: VideoCommentThreadTreeServerModel) {
- if (!tree) return tree as VideoCommentThreadTree
+ private extractVideoCommentTree (serverTree: VideoCommentThreadTreeServerModel): VideoCommentThreadTree {
+ if (!serverTree) return null
- tree.comment = new VideoComment(tree.comment)
- tree.children.forEach(c => this.extractVideoCommentTree(c))
+ const tree = {
+ comment: new VideoComment(serverTree.comment),
+ children: serverTree.children.map(c => this.extractVideoCommentTree(c))
+ }
+
+ const hasDisplayedChildren = tree.children.length === 0
+ ? !tree.comment.isDeleted
+ : tree.children.some(c => c.hasDisplayedChildren)
- return tree as VideoCommentThreadTree
+ return Object.assign(tree, { hasDisplayedChildren })
}
private buildParamsFromSearch (search: string, params: HttpParams) {
const filters = this.restService.parseQueryStringFilter(search, {
isLocal: {
prefix: 'local:',
- isBoolean: true,
- handler: v => {
- if (v === 'true') return v
- if (v === 'false') return v
-
- return undefined
- }
+ isBoolean: true
},
searchAccount: { prefix: 'account:' },