Fix bulk finder

This commit is contained in:
Chocobozzz 2024-06-20 09:05:09 +02:00
parent 802601c241
commit 1b9b904c18
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 5 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import { uniq } from 'lodash-es' import { uniq } from 'lodash-es'
import { Observable, timer } from 'rxjs' import { Observable } from 'rxjs'
import { buffer, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators' import { buffer, debounceTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators'
function buildBulkObservable <P extends number | string, R> (options: { function buildBulkObservable <P extends number | string, R> (options: {
notifierObservable: Observable<P> notifierObservable: Observable<P>
@ -11,7 +11,7 @@ function buildBulkObservable <P extends number | string, R> (options: {
return notifierObservable.pipe( return notifierObservable.pipe(
distinctUntilChanged(), distinctUntilChanged(),
buffer(timer(time)), buffer(notifierObservable.pipe(debounceTime(time))),
filter(params => params.length !== 0), filter(params => params.length !== 0),
map(params => uniq(params)), map(params => uniq(params)),
switchMap(params => { switchMap(params => {

View File

@ -39,7 +39,7 @@ export class UserSubscriptionService {
) { ) {
this.existsObservable = merge( this.existsObservable = merge(
buildBulkObservable({ buildBulkObservable({
time: 500, time: 200,
notifierObservable: this.existsSubject, notifierObservable: this.existsSubject,
bulkGet: this.doSubscriptionsExist.bind(this) bulkGet: this.doSubscriptionsExist.bind(this)
}).pipe(map(r => r.response)), }).pipe(map(r => r.response)),

View File

@ -58,7 +58,7 @@ export class VideoPlaylistService {
) { ) {
this.videoExistsInPlaylistObservable = merge( this.videoExistsInPlaylistObservable = merge(
buildBulkObservable({ buildBulkObservable({
time: 5000, time: 200,
bulkGet: (videoIds: number[]) => { bulkGet: (videoIds: number[]) => {
// We added a delay to the request, so ensure the user is still logged in // We added a delay to the request, so ensure the user is still logged in
if (this.auth.isLoggedIn()) { if (this.auth.isLoggedIn()) {