diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-14 11:50:22 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-10-14 11:50:22 +0200 |
commit | afb7d2d5c6ca09d2c678781ae4dd3f527604c1b4 (patch) | |
tree | e0b9c2039c541f5866c596b1531f820fc938ca50 /client/src/app/helpers | |
parent | 37cd44d04f2ad4d90535d28340c78d8d85b31f18 (diff) | |
download | PeerTube-afb7d2d5c6ca09d2c678781ae4dd3f527604c1b4.tar.gz PeerTube-afb7d2d5c6ca09d2c678781ae4dd3f527604c1b4.tar.zst PeerTube-afb7d2d5c6ca09d2c678781ae4dd3f527604c1b4.zip |
Remove protractor workaround
We don't use it anymore
Diffstat (limited to 'client/src/app/helpers')
-rw-r--r-- | client/src/app/helpers/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/helpers/rxjs.ts | 13 | ||||
-rw-r--r-- | client/src/app/helpers/zone.ts | 40 |
3 files changed, 4 insertions, 50 deletions
diff --git a/client/src/app/helpers/index.ts b/client/src/app/helpers/index.ts index beff749ec..8cdda83f3 100644 --- a/client/src/app/helpers/index.ts +++ b/client/src/app/helpers/index.ts | |||
@@ -3,4 +3,3 @@ export * from './constants' | |||
3 | export * from './i18n-utils' | 3 | export * from './i18n-utils' |
4 | export * from './rxjs' | 4 | export * from './rxjs' |
5 | export * from './utils' | 5 | export * from './utils' |
6 | export * from './zone' | ||
diff --git a/client/src/app/helpers/rxjs.ts b/client/src/app/helpers/rxjs.ts index eb051f868..625bca0f7 100644 --- a/client/src/app/helpers/rxjs.ts +++ b/client/src/app/helpers/rxjs.ts | |||
@@ -1,24 +1,19 @@ | |||
1 | import { uniq } from 'lodash-es' | 1 | import { uniq } from 'lodash-es' |
2 | import { asyncScheduler, Observable } from 'rxjs' | 2 | import { Observable } from 'rxjs' |
3 | import { bufferTime, distinctUntilChanged, filter, map, observeOn, share, switchMap } from 'rxjs/operators' | 3 | import { bufferTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators' |
4 | import { NgZone } from '@angular/core' | ||
5 | import { enterZone, leaveZone } from './zone' | ||
6 | 4 | ||
7 | function buildBulkObservable <T extends number | string, R> (options: { | 5 | function buildBulkObservable <T extends number | string, R> (options: { |
8 | ngZone: NgZone | ||
9 | notifierObservable: Observable<T> | 6 | notifierObservable: Observable<T> |
10 | time: number | 7 | time: number |
11 | bulkGet: (params: T[]) => Observable<R> | 8 | bulkGet: (params: T[]) => Observable<R> |
12 | }) { | 9 | }) { |
13 | const { ngZone, notifierObservable, time, bulkGet } = options | 10 | const { notifierObservable, time, bulkGet } = options |
14 | 11 | ||
15 | return notifierObservable.pipe( | 12 | return notifierObservable.pipe( |
16 | distinctUntilChanged(), | 13 | distinctUntilChanged(), |
17 | // We leave Angular zone so Protractor does not get stuck | 14 | bufferTime(time), |
18 | bufferTime(time, leaveZone(ngZone, asyncScheduler)), | ||
19 | filter(params => params.length !== 0), | 15 | filter(params => params.length !== 0), |
20 | map(params => uniq(params)), | 16 | map(params => uniq(params)), |
21 | observeOn(enterZone(ngZone, asyncScheduler)), | ||
22 | switchMap(params => bulkGet(params)), | 17 | switchMap(params => bulkGet(params)), |
23 | share() | 18 | share() |
24 | ) | 19 | ) |
diff --git a/client/src/app/helpers/zone.ts b/client/src/app/helpers/zone.ts deleted file mode 100644 index 74eed7032..000000000 --- a/client/src/app/helpers/zone.ts +++ /dev/null | |||
@@ -1,40 +0,0 @@ | |||
1 | import { SchedulerLike, Subscription } from 'rxjs' | ||
2 | import { NgZone } from '@angular/core' | ||
3 | |||
4 | class LeaveZoneScheduler implements SchedulerLike { | ||
5 | constructor (private zone: NgZone, private scheduler: SchedulerLike) { | ||
6 | } | ||
7 | |||
8 | schedule (...args: any[]): Subscription { | ||
9 | return this.zone.runOutsideAngular(() => | ||
10 | this.scheduler.schedule.apply(this.scheduler, args) | ||
11 | ) | ||
12 | } | ||
13 | |||
14 | now (): number { | ||
15 | return this.scheduler.now() | ||
16 | } | ||
17 | } | ||
18 | |||
19 | class EnterZoneScheduler implements SchedulerLike { | ||
20 | constructor (private zone: NgZone, private scheduler: SchedulerLike) { | ||
21 | } | ||
22 | |||
23 | schedule (...args: any[]): Subscription { | ||
24 | return this.zone.run(() => | ||
25 | this.scheduler.schedule.apply(this.scheduler, args) | ||
26 | ) | ||
27 | } | ||
28 | |||
29 | now (): number { | ||
30 | return this.scheduler.now() | ||
31 | } | ||
32 | } | ||
33 | |||
34 | export function leaveZone (zone: NgZone, scheduler: SchedulerLike): SchedulerLike { | ||
35 | return new LeaveZoneScheduler(zone, scheduler) | ||
36 | } | ||
37 | |||
38 | export function enterZone (zone: NgZone, scheduler: SchedulerLike): SchedulerLike { | ||
39 | return new EnterZoneScheduler(zone, scheduler) | ||
40 | } | ||