-import { Observable } from 'rxjs'
-import { catchError, map } from 'rxjs/operators'
+import { SortMeta } from 'primeng/api'
+import { from, Observable } from 'rxjs'
+import { catchError, concatMap, map, toArray } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
import { ComponentPaginationLight, RestExtractor, RestPagination, RestService } from '@app/core'
import { environment } from '../../../environments/environment'
import { VideoCommentThreadTree } from './video-comment-thread-tree.model'
import { VideoComment } from './video-comment.model'
import { environment } from '../../../environments/environment'
import { VideoCommentThreadTree } from './video-comment-thread-tree.model'
import { VideoComment } from './video-comment.model'
videoId: number | string,
componentPagination: ComponentPaginationLight,
sort: string
videoId: number | string,
componentPagination: ComponentPaginationLight,
sort: string
const { videoId, componentPagination, sort } = parameters
const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
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'
params = this.restService.addRestGetParams(params, pagination, sort)
const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads'
.pipe(
map(result => this.extractVideoComments(result)),
catchError(err => this.restExtractor.handleError(err))
.pipe(
map(result => this.extractVideoComments(result)),
catchError(err => this.restExtractor.handleError(err))
const videoCommentsJson = result.data
const totalComments = result.total
const comments: VideoComment[] = []
const videoCommentsJson = result.data
const totalComments = result.total
const comments: VideoComment[] = []
- private extractVideoCommentTree (tree: VideoCommentThreadTreeServerModel) {
- if (!tree) return tree as VideoCommentThreadTree
+ private extractVideoCommentTree (serverTree: VideoCommentThreadTreeServerModel): VideoCommentThreadTree {
+ if (!serverTree) return null
+
+ const tree = {
+ comment: new VideoComment(serverTree.comment),
+ children: serverTree.children.map(c => this.extractVideoCommentTree(c))
+ }
- tree.comment = new VideoComment(tree.comment)
- tree.children.forEach(c => this.extractVideoCommentTree(c))
+ const hasDisplayedChildren = tree.children.length === 0
+ ? !tree.comment.isDeleted
+ : tree.children.some(c => c.hasDisplayedChildren)
}
private buildParamsFromSearch (search: string, params: HttpParams) {
const filters = this.restService.parseQueryStringFilter(search, {
isLocal: {
prefix: 'local:',
}
private buildParamsFromSearch (search: string, params: HttpParams) {
const filters = this.restService.parseQueryStringFilter(search, {
isLocal: {
prefix: 'local:',