import * as debug from 'debug'
import { Observable, Subject } from 'rxjs'
-import { first, map } from 'rxjs/operators'
+import { filter, first, map } from 'rxjs/operators'
import { Injectable } from '@angular/core'
import { buildBulkObservable } from '@app/helpers'
import { ResultList } from '@shared/models/common'
type BulkObservables <P extends number | string, R> = {
notifier: Subject<P>
- result: Observable<R>
+ result: Observable<{ params: P[], response: R }>
}
@Injectable()
return new Observable<R>(obs => {
observableObject.result
.pipe(
+ filter(result => result.params.includes(param)),
first(),
- map(({ data }) => data),
+ map(result => result.response.data),
map(data => data.find(finder))
)
.subscribe(result => {
private getVideosInBulk (uuids: string[]) {
logger('Fetching videos %s.', uuids.join(', '))
- return this.searchService.searchVideos({ uuids })
+ return this.searchService.searchVideos({ uuids, componentPagination: { itemsPerPage: uuids.length, currentPage: 1 } })
}
private getChannelsInBulk (handles: string[]) {
logger('Fetching channels %s.', handles.join(', '))
- return this.searchService.searchVideoChannels({ handles })
+ return this.searchService.searchVideoChannels({ handles, componentPagination: { itemsPerPage: handles.length, currentPage: 1 } })
}
private getPlaylistsInBulk (uuids: string[]) {
logger('Fetching playlists %s.', uuids.join(', '))
- return this.searchService.searchVideoPlaylists({ uuids })
+ return this.searchService.searchVideoPlaylists({ uuids, componentPagination: { itemsPerPage: uuids.length, currentPage: 1 } })
}
- private buildBulkObservableObject <T extends number | string, R> (bulkGet: (params: T[]) => Observable<R>) {
- const notifier = new Subject<T>()
+ private buildBulkObservableObject <P extends number | string, R> (bulkGet: (params: P[]) => Observable<R>) {
+ const notifier = new Subject<P>()
return {
notifier,