- return this.videoService.getMyVideos(newPagination, this.sort, this.videosSearch)
- .pipe(
- tap(res => this.pagination.totalItems = res.total)
- )
+ return this.videoService.getMyVideos({
+ videoPagination: newPagination,
+ sort: this.sort,
+ userChannels: this.userChannels,
+ search: this.search
+ }).pipe(
+ tap(res => this.pagination.totalItems = res.total),
+ tap(({ data }) => this.fetchVideosContainedInPlaylists(data))
+ )
+ }
+
+ private fetchVideosContainedInPlaylists (videos: Video[]) {
+ this.playlistService.doVideosExistInPlaylist(videos.map(v => v.id))
+ .subscribe(result => {
+ this.videosContainedInPlaylists = Object.keys(result).reduce((acc, videoId) => ({
+ ...acc,
+ [videoId]: uniqBy(result[+videoId], (p: VideoExistInPlaylist) => p.playlistId)
+ }), this.videosContainedInPlaylists)
+ })