]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-video-playlist/video-playlist.service.ts
Fix find in bulk
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-playlist / video-playlist.service.ts
index a3f1393ff3318929d33fa462a93fe2fd0ca0d3fe..fc291329ad5ecb8a72879a54ed506eb1fd289644 100644 (file)
@@ -2,7 +2,7 @@ import * as debug from 'debug'
 import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
 import { catchError, filter, map, share, switchMap, tap } from 'rxjs/operators'
 import { HttpClient, HttpParams } from '@angular/common/http'
-import { Injectable, NgZone } from '@angular/core'
+import { Injectable } from '@angular/core'
 import { AuthUser, ComponentPaginationLight, RestExtractor, RestService, ServerService } from '@app/core'
 import { buildBulkObservable, objectToFormData } from '@app/helpers'
 import { Account, AccountService, VideoChannel, VideoChannelService } from '@app/shared/shared-main'
@@ -47,16 +47,14 @@ export class VideoPlaylistService {
     private authHttp: HttpClient,
     private serverService: ServerService,
     private restExtractor: RestExtractor,
-    private restService: RestService,
-    private ngZone: NgZone
+    private restService: RestService
   ) {
     this.videoExistsInPlaylistObservable = merge(
       buildBulkObservable({
         time: 500,
-        ngZone: this.ngZone,
         bulkGet: this.doVideosExistInPlaylist.bind(this),
         notifierObservable: this.videoExistsInPlaylistNotifier
-      }),
+      }).pipe(map(({ response }) => response)),
 
       this.videoExistsInPlaylistCacheSubject
     )
@@ -256,12 +254,12 @@ export class VideoPlaylistService {
                )
   }
 
-  getPlaylistVideos (
-    videoPlaylistId: number | string,
+  getPlaylistVideos (options: {
+    videoPlaylistId: number | string
     componentPagination: ComponentPaginationLight
-  ): Observable<ResultList<VideoPlaylistElement>> {
-    const path = VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + videoPlaylistId + '/videos'
-    const pagination = this.restService.componentPaginationToRestPagination(componentPagination)
+  }): Observable<ResultList<VideoPlaylistElement>> {
+    const path = VideoPlaylistService.BASE_VIDEO_PLAYLIST_URL + options.videoPlaylistId + '/videos'
+    const pagination = this.restService.componentPaginationToRestPagination(options.componentPagination)
 
     let params = new HttpParams()
     params = this.restService.addRestGetParams(params, pagination)
@@ -279,18 +277,18 @@ export class VideoPlaylistService {
   }
 
   listenToVideoPlaylistChange (videoId: number) {
-    if (this.videoExistsObservableCache[ videoId ]) {
-      return this.videoExistsObservableCache[ videoId ]
+    if (this.videoExistsObservableCache[videoId]) {
+      return this.videoExistsObservableCache[videoId]
     }
 
     const obs = this.videoExistsInPlaylistObservable
                     .pipe(
-                      map(existsResult => existsResult[ videoId ]),
+                      map(existsResult => existsResult[videoId]),
                       filter(r => !!r),
-                      tap(result => this.videoExistsCache[ videoId ] = result)
+                      tap(result => this.videoExistsCache[videoId] = result)
                     )
 
-    this.videoExistsObservableCache[ videoId ] = obs
+    this.videoExistsObservableCache[videoId] = obs
     return obs
   }