Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix find in bulk

Chocobozzz2cc276f92fef
diff --git a/client/src/app/helpers/rxjs.ts b/client/src/app/helpers/rxjs.ts
index 625bca0f7d..2eaf0a0554 100644
--- a/client/src/app/helpers/rxjs.ts
+++ b/client/src/app/helpers/rxjs.ts
@@ -2,10 +2,10 @@ import { uniq } from 'lodash-es'
import { Observable } from 'rxjs'
import { bufferTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators'
-function buildBulkObservable <T extends number | string, R> (options: {
- notifierObservable: Observable<T>
+function buildBulkObservable <P extends number | string, R> (options: {
+ notifierObservable: Observable<P>
time: number
- bulkGet: (params: T[]) => Observable<R>
+ bulkGet: (params: P[]) => Observable<R>
}) {
const { notifierObservable, time, bulkGet } = options
@@ -14,7 +14,10 @@ function buildBulkObservable <T extends number | string, R> (options: {
bufferTime(time),
filter(params => params.length !== 0),
map(params => uniq(params)),
- switchMap(params => bulkGet(params)),
+ switchMap(params => {
+ return bulkGet(params)
+ .pipe(map(response => ({ params, response })))
+ }),
share()
)
}
diff --git a/client/src/app/shared/shared-search/find-in-bulk.service.ts b/client/src/app/shared/shared-search/find-in-bulk.service.ts
index 6d77941d3c..30cddc1544 100644
--- a/client/src/app/shared/shared-search/find-in-bulk.service.ts
+++ b/client/src/app/shared/shared-search/find-in-bulk.service.ts
@@ -1,6 +1,6 @@
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'
@@ -12,7 +12,7 @@ const logger = debug('peertube:search:FindInBulkService')
type BulkObservables <P extends number | string, R> = {
notifier: Subject<P>
- result: Observable<R>
+ result: Observable<{ params: P[], response: R }>
}
@Injectable()
@@ -70,8 +70,9 @@ export class FindInBulkService {
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 => {
@@ -105,8 +106,8 @@ export class FindInBulkService {
return this.searchService.searchVideoPlaylists({ uuids })
}
- 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,
diff --git a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
index 8d2de81739..f289fb6cff 100644
--- a/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
+++ b/client/src/app/shared/shared-user-subscription/user-subscription.service.ts
@@ -37,7 +37,7 @@ export class UserSubscriptionService {
time: 500,
notifierObservable: this.existsSubject,
bulkGet: this.doSubscriptionsExist.bind(this)
- }),
+ }).pipe(map(r => r.response)),
this.myAccountSubscriptionCacheSubject
)
diff --git a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts
index 02632c9eb9..fc291329ad 100644
--- a/client/src/app/shared/shared-video-playlist/video-playlist.service.ts
+++ b/client/src/app/shared/shared-video-playlist/video-playlist.service.ts
@@ -54,7 +54,7 @@ export class VideoPlaylistService {
time: 500,
bulkGet: this.doVideosExistInPlaylist.bind(this),
notifierObservable: this.videoExistsInPlaylistNotifier
- }),
+ }).pipe(map(({ response }) => response)),
this.videoExistsInPlaylistCacheSubject
)