diff options
Diffstat (limited to 'client/src/app/shared/user-subscription')
-rw-r--r-- | client/src/app/shared/user-subscription/user-subscription.service.ts | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/client/src/app/shared/user-subscription/user-subscription.service.ts b/client/src/app/shared/user-subscription/user-subscription.service.ts index bfb5848bc..9af9ba23e 100644 --- a/client/src/app/shared/user-subscription/user-subscription.service.ts +++ b/client/src/app/shared/user-subscription/user-subscription.service.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { bufferTime, catchError, filter, map, tap, share, switchMap } from 'rxjs/operators' | 1 | import { bufferTime, catchError, filter, map, observeOn, share, switchMap, tap } from 'rxjs/operators' |
2 | import { Observable, ReplaySubject, Subject, of, merge } from 'rxjs' | 2 | import { asyncScheduler, merge, Observable, of, ReplaySubject, Subject } from 'rxjs' |
3 | import { HttpClient, HttpParams } from '@angular/common/http' | 3 | import { HttpClient, HttpParams } from '@angular/common/http' |
4 | import { Injectable } from '@angular/core' | 4 | import { Injectable, NgZone } from '@angular/core' |
5 | import { ResultList } from '../../../../../shared' | 5 | import { ResultList } from '../../../../../shared' |
6 | import { environment } from '../../../environments/environment' | 6 | import { environment } from '../../../environments/environment' |
7 | import { RestExtractor, RestService } from '../rest' | 7 | import { RestExtractor, RestService } from '../rest' |
@@ -11,6 +11,7 @@ import { VideoChannel as VideoChannelServer } from '../../../../../shared/models | |||
11 | import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model' | 11 | import { ComponentPaginationLight } from '@app/shared/rest/component-pagination.model' |
12 | import { uniq } from 'lodash-es' | 12 | import { uniq } from 'lodash-es' |
13 | import * as debug from 'debug' | 13 | import * as debug from 'debug' |
14 | import { enterZone, leaveZone } from '@app/shared/rxjs/zone' | ||
14 | 15 | ||
15 | const logger = debug('peertube:subscriptions:UserSubscriptionService') | 16 | const logger = debug('peertube:subscriptions:UserSubscriptionService') |
16 | 17 | ||
@@ -32,13 +33,16 @@ export class UserSubscriptionService { | |||
32 | constructor ( | 33 | constructor ( |
33 | private authHttp: HttpClient, | 34 | private authHttp: HttpClient, |
34 | private restExtractor: RestExtractor, | 35 | private restExtractor: RestExtractor, |
35 | private restService: RestService | 36 | private restService: RestService, |
37 | private ngZone: NgZone | ||
36 | ) { | 38 | ) { |
37 | this.existsObservable = merge( | 39 | this.existsObservable = merge( |
38 | this.existsSubject.pipe( | 40 | this.existsSubject.pipe( |
39 | bufferTime(500), | 41 | // We leave Angular zone so Protractor does not get stuck |
42 | bufferTime(500, leaveZone(this.ngZone, asyncScheduler)), | ||
40 | filter(uris => uris.length !== 0), | 43 | filter(uris => uris.length !== 0), |
41 | map(uris => uniq(uris)), | 44 | map(uris => uniq(uris)), |
45 | observeOn(enterZone(this.ngZone, asyncScheduler)), | ||
42 | switchMap(uris => this.doSubscriptionsExist(uris)), | 46 | switchMap(uris => this.doSubscriptionsExist(uris)), |
43 | share() | 47 | share() |
44 | ), | 48 | ), |