aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-user-subscription
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-user-subscription
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-user-subscription')
-rw-r--r--client/src/app/shared/shared-user-subscription/user-subscription.service.ts22
1 files changed, 9 insertions, 13 deletions
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 eb1fdf91c..bb44660d2 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
@@ -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, switchMap, tap } from 'rxjs/operators'
4import { bufferTime, catchError, filter, map, observeOn, share, switchMap, tap } 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 { ComponentPaginationLight, RestExtractor, RestService } from '@app/core' 6import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core'
8import { enterZone, leaveZone } from '@app/helpers' 7import { buildBulkObservable } from '@app/helpers'
9import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main' 8import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
10import { ResultList, VideoChannel as VideoChannelServer, VideoSortField } from '@shared/models' 9import { ResultList, VideoChannel as VideoChannelServer, VideoSortField } from '@shared/models'
11import { environment } from '../../../environments/environment' 10import { environment } from '../../../environments/environment'
@@ -35,15 +34,12 @@ export class UserSubscriptionService {
35 private ngZone: NgZone 34 private ngZone: NgZone
36 ) { 35 ) {
37 this.existsObservable = merge( 36 this.existsObservable = merge(
38 this.existsSubject.pipe( 37 buildBulkObservable({
39 // We leave Angular zone so Protractor does not get stuck 38 time: 500,
40 bufferTime(500, leaveZone(this.ngZone, asyncScheduler)), 39 ngZone: this.ngZone,
41 filter(uris => uris.length !== 0), 40 notifierObservable: this.existsSubject,
42 map(uris => uniq(uris)), 41 bulkGet: this.doSubscriptionsExist.bind(this)
43 observeOn(enterZone(this.ngZone, asyncScheduler)), 42 }),
44 switchMap(uris => this.doSubscriptionsExist(uris)),
45 share()
46 ),
47 43
48 this.myAccountSubscriptionCacheSubject 44 this.myAccountSubscriptionCacheSubject
49 ) 45 )