aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-video-playlist
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-02 15:29:09 +0200
committerChocobozzz <me@florianbigard.com>2021-08-02 15:40:09 +0200
commit3da38d6e9f8d600476be276666ac7223aa5f172c (patch)
treedaec25cccb900a0f90fc9d2273099683b42d8551 /client/src/app/shared/shared-video-playlist
parent200eaf5152ca72fe6b05a49caf819e22bd045b37 (diff)
downloadPeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.tar.gz
PeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.tar.zst
PeerTube-3da38d6e9f8d600476be276666ac7223aa5f172c.zip
Fetch things in bulk for the homepage
Diffstat (limited to 'client/src/app/shared/shared-video-playlist')
-rw-r--r--client/src/app/shared/shared-video-playlist/video-playlist.service.ts23
1 files changed, 9 insertions, 14 deletions
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 1b87e0b2a..a3f1393ff 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
@@ -1,11 +1,10 @@
1import * as debug from 'debug' 1import * as debug from 'debug'
2import { uniq } from 'lodash-es' 2import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
3import { asyncScheduler, merge, Observable, of, ReplaySubject, Subject } from 'rxjs' 3import { catchError, filter, map, share, switchMap, tap } from 'rxjs/operators'
4import { bufferTime, catchError, filter, map, observeOn, share, switchMap, tap, distinctUntilChanged } from 'rxjs/operators'
5import { HttpClient, HttpParams } from '@angular/common/http' 4import { HttpClient, HttpParams } from '@angular/common/http'
6import { Injectable, NgZone } from '@angular/core' 5import { Injectable, NgZone } from '@angular/core'
7import { AuthUser, ComponentPaginationLight, RestExtractor, RestService, ServerService } from '@app/core' 6import { AuthUser, ComponentPaginationLight, RestExtractor, RestService, ServerService } from '@app/core'
8import { enterZone, leaveZone, objectToFormData } from '@app/helpers' 7import { buildBulkObservable, objectToFormData } from '@app/helpers'
9import { Account, AccountService, VideoChannel, VideoChannelService } from '@app/shared/shared-main' 8import { Account, AccountService, VideoChannel, VideoChannelService } from '@app/shared/shared-main'
10import { 9import {
11 ResultList, 10 ResultList,
@@ -52,16 +51,12 @@ export class VideoPlaylistService {
52 private ngZone: NgZone 51 private ngZone: NgZone
53 ) { 52 ) {
54 this.videoExistsInPlaylistObservable = merge( 53 this.videoExistsInPlaylistObservable = merge(
55 this.videoExistsInPlaylistNotifier.pipe( 54 buildBulkObservable({
56 distinctUntilChanged(), 55 time: 500,
57 // We leave Angular zone so Protractor does not get stuck 56 ngZone: this.ngZone,
58 bufferTime(500, leaveZone(this.ngZone, asyncScheduler)), 57 bulkGet: this.doVideosExistInPlaylist.bind(this),
59 filter(videoIds => videoIds.length !== 0), 58 notifierObservable: this.videoExistsInPlaylistNotifier
60 map(videoIds => uniq(videoIds)), 59 }),
61 observeOn(enterZone(this.ngZone, asyncScheduler)),
62 switchMap(videoIds => this.doVideosExistInPlaylist(videoIds)),
63 share()
64 ),
65 60
66 this.videoExistsInPlaylistCacheSubject 61 this.videoExistsInPlaylistCacheSubject
67 ) 62 )