diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-18 11:44:54 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-18 11:44:54 +0200 |
commit | 2cc276f92fefeff88fcc74217e1174a3ddb3f074 (patch) | |
tree | 1f87381575de9500d96739cf85321e3e5edb0bf7 /client/src/app/helpers | |
parent | 27c3c9456dcf436946635c3c85d4a7653b5cccdb (diff) | |
download | PeerTube-2cc276f92fefeff88fcc74217e1174a3ddb3f074.tar.gz PeerTube-2cc276f92fefeff88fcc74217e1174a3ddb3f074.tar.zst PeerTube-2cc276f92fefeff88fcc74217e1174a3ddb3f074.zip |
Fix find in bulk
Diffstat (limited to 'client/src/app/helpers')
-rw-r--r-- | client/src/app/helpers/rxjs.ts | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/client/src/app/helpers/rxjs.ts b/client/src/app/helpers/rxjs.ts index 625bca0f7..2eaf0a055 100644 --- a/client/src/app/helpers/rxjs.ts +++ b/client/src/app/helpers/rxjs.ts | |||
@@ -2,10 +2,10 @@ import { uniq } from 'lodash-es' | |||
2 | import { Observable } from 'rxjs' | 2 | import { Observable } from 'rxjs' |
3 | import { bufferTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators' | 3 | import { bufferTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators' |
4 | 4 | ||
5 | function buildBulkObservable <T extends number | string, R> (options: { | 5 | function buildBulkObservable <P extends number | string, R> (options: { |
6 | notifierObservable: Observable<T> | 6 | notifierObservable: Observable<P> |
7 | time: number | 7 | time: number |
8 | bulkGet: (params: T[]) => Observable<R> | 8 | bulkGet: (params: P[]) => Observable<R> |
9 | }) { | 9 | }) { |
10 | const { notifierObservable, time, bulkGet } = options | 10 | const { notifierObservable, time, bulkGet } = options |
11 | 11 | ||
@@ -14,7 +14,10 @@ function buildBulkObservable <T extends number | string, R> (options: { | |||
14 | bufferTime(time), | 14 | bufferTime(time), |
15 | filter(params => params.length !== 0), | 15 | filter(params => params.length !== 0), |
16 | map(params => uniq(params)), | 16 | map(params => uniq(params)), |
17 | switchMap(params => bulkGet(params)), | 17 | switchMap(params => { |
18 | return bulkGet(params) | ||
19 | .pipe(map(response => ({ params, response }))) | ||
20 | }), | ||
18 | share() | 21 | share() |
19 | ) | 22 | ) |
20 | } | 23 | } |