ActivityPub-federated video streaming platform using P2P directly in your web browser
Remove protractor workaround
Chocobozzzafb7d2d5c6ca
diff --git a/client/e2e/src/po/player.po.ts b/client/e2e/src/po/player.po.tsindex fca3bcdbab..a20e683bce 100644--- a/client/e2e/src/po/player.po.ts+++ b/client/e2e/src/po/player.po.ts@@ -35,7 +35,7 @@ export class PlayerPage {// Autoplay is disabled on iOS and Safariif (isIOS() || isSafari() || isMobileDevice()) {- // We can't play the video using protractor if it is not muted+ // We can't play the video if it is not mutedawait browser.execute(`document.querySelector('video').muted = true`)await this.clickOnPlayButton()} else if (isAutoplay === false) {diff --git a/client/src/app/core/notification/peertube-socket.service.ts b/client/src/app/core/notification/peertube-socket.service.tsindex 50d5df68f4..0db86d8e7f 100644--- a/client/src/app/core/notification/peertube-socket.service.ts+++ b/client/src/app/core/notification/peertube-socket.service.ts@@ -1,9 +1,9 @@import { Subject } from 'rxjs'-import { Injectable, NgZone } from '@angular/core'+import { io, Socket } from 'socket.io-client'+import { Injectable } from '@angular/core'import { LiveVideoEventPayload, LiveVideoEventType, UserNotification as UserNotificationServer } from '@shared/models'import { environment } from '../../../environments/environment'import { AuthService } from '../auth'-import { io, Socket } from 'socket.io-client'export type NotificationEvent = 'new' | 'read' | 'read-all'@@ -18,8 +18,7 @@ export class PeerTubeSocket {private liveVideosSocket: Socketconstructor (- private auth: AuthService,- private ngZone: NgZone+ private auth: AuthService) {}async getMyNotificationsSocket () {@@ -53,15 +52,12 @@ export class PeerTubeSocket {await this.importIOIfNeeded()- // Prevent protractor issues https://github.com/angular/angular/issues/11853- this.ngZone.runOutsideAngular(() => {- this.notificationSocket = this.io(environment.apiUrl + '/user-notifications', {- query: { accessToken: this.auth.getAccessToken() }- })+ this.notificationSocket = this.io(environment.apiUrl + '/user-notifications', {+ query: { accessToken: this.auth.getAccessToken() }})this.notificationSocket.on('new-notification', (n: UserNotificationServer) => {- this.ngZone.run(() => this.dispatchNotificationEvent('new', n))+ this.dispatchNotificationEvent('new', n)})}@@ -70,16 +66,13 @@ export class PeerTubeSocket {await this.importIOIfNeeded()- // Prevent protractor issues https://github.com/angular/angular/issues/11853- this.ngZone.runOutsideAngular(() => {- this.liveVideosSocket = this.io(environment.apiUrl + '/live-videos')- })+ this.liveVideosSocket = this.io(environment.apiUrl + '/live-videos')const types: LiveVideoEventType[] = [ 'views-change', 'state-change' ]for (const type of types) {this.liveVideosSocket.on(type, (payload: LiveVideoEventPayload) => {- this.ngZone.run(() => this.dispatchLiveVideoEvent(type, payload))+ this.dispatchLiveVideoEvent(type, payload)})}}diff --git a/client/src/app/helpers/index.ts b/client/src/app/helpers/index.tsindex beff749ec5..8cdda83f3a 100644--- a/client/src/app/helpers/index.ts+++ b/client/src/app/helpers/index.ts@@ -3,4 +3,3 @@ export * from './constants'export * from './i18n-utils'export * from './rxjs'export * from './utils'-export * from './zone'diff --git a/client/src/app/helpers/rxjs.ts b/client/src/app/helpers/rxjs.tsindex eb051f8688..625bca0f7d 100644--- a/client/src/app/helpers/rxjs.ts+++ b/client/src/app/helpers/rxjs.ts@@ -1,24 +1,19 @@import { uniq } from 'lodash-es'-import { asyncScheduler, Observable } from 'rxjs'-import { bufferTime, distinctUntilChanged, filter, map, observeOn, share, switchMap } from 'rxjs/operators'-import { NgZone } from '@angular/core'-import { enterZone, leaveZone } from './zone'+import { Observable } from 'rxjs'+import { bufferTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators'function buildBulkObservable <T extends number | string, R> (options: {- ngZone: NgZonenotifierObservable: Observable<T>time: numberbulkGet: (params: T[]) => Observable<R>}) {- const { ngZone, notifierObservable, time, bulkGet } = options+ const { notifierObservable, time, bulkGet } = optionsreturn notifierObservable.pipe(distinctUntilChanged(),- // We leave Angular zone so Protractor does not get stuck- bufferTime(time, leaveZone(ngZone, asyncScheduler)),+ bufferTime(time),filter(params => params.length !== 0),map(params => uniq(params)),- observeOn(enterZone(ngZone, asyncScheduler)),switchMap(params => bulkGet(params)),share())diff --git a/client/src/app/helpers/zone.ts b/client/src/app/helpers/zone.tsdeleted file mode 100644index 74eed7032d..0000000000--- a/client/src/app/helpers/zone.ts+++ /dev/null@@ -1,40 +0,0 @@-import { SchedulerLike, Subscription } from 'rxjs'-import { NgZone } from '@angular/core'--class LeaveZoneScheduler implements SchedulerLike {- constructor (private zone: NgZone, private scheduler: SchedulerLike) {- }-- schedule (...args: any[]): Subscription {- return this.zone.runOutsideAngular(() =>- this.scheduler.schedule.apply(this.scheduler, args)- )- }-- now (): number {- return this.scheduler.now()- }-}--class EnterZoneScheduler implements SchedulerLike {- constructor (private zone: NgZone, private scheduler: SchedulerLike) {- }-- schedule (...args: any[]): Subscription {- return this.zone.run(() =>- this.scheduler.schedule.apply(this.scheduler, args)- )- }-- now (): number {- return this.scheduler.now()- }-}--export function leaveZone (zone: NgZone, scheduler: SchedulerLike): SchedulerLike {- return new LeaveZoneScheduler(zone, scheduler)-}--export function enterZone (zone: NgZone, scheduler: SchedulerLike): SchedulerLike {- return new EnterZoneScheduler(zone, scheduler)-}diff --git a/client/src/app/shared/shared-search/find-in-bulk.service.ts b/client/src/app/shared/shared-search/find-in-bulk.service.tsindex 962e374a54..6d77941d3c 100644--- a/client/src/app/shared/shared-search/find-in-bulk.service.ts+++ b/client/src/app/shared/shared-search/find-in-bulk.service.ts@@ -1,7 +1,7 @@import * as debug from 'debug'import { Observable, Subject } from 'rxjs'import { first, map } from 'rxjs/operators'-import { Injectable, NgZone } from '@angular/core'+import { Injectable } from '@angular/core'import { buildBulkObservable } from '@app/helpers'import { ResultList } from '@shared/models/common'import { Video, VideoChannel } from '../shared-main'@@ -23,8 +23,7 @@ export class FindInBulkService {private getPlaylistInBulk: BulkObservables<string, ResultList<VideoPlaylist>>constructor (- private searchService: SearchService,- private ngZone: NgZone+ private searchService: SearchService) {this.getVideoInBulk = this.buildBulkObservableObject(this.getVideosInBulk.bind(this))this.getChannelInBulk = this.buildBulkObservableObject(this.getChannelsInBulk.bind(this))@@ -115,7 +114,6 @@ export class FindInBulkService {result: buildBulkObservable({time: 500,bulkGet,- ngZone: this.ngZone,notifierObservable: notifier.asObservable()})}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.tsindex e4fc09b368..8d2de81739 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@@ -2,7 +2,7 @@ import * as debug from 'debug'import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'import { catchError, filter, map, switchMap, tap } from 'rxjs/operators'import { HttpClient, HttpParams } from '@angular/common/http'-import { Injectable, NgZone } from '@angular/core'+import { Injectable } from '@angular/core'import { ComponentPaginationLight, RestExtractor, RestService } from '@app/core'import { buildBulkObservable } from '@app/helpers'import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'@@ -30,13 +30,11 @@ export class UserSubscriptionService {private authHttp: HttpClient,private restExtractor: RestExtractor,private videoService: VideoService,- private restService: RestService,- private ngZone: NgZone+ private restService: RestService) {this.existsObservable = merge(buildBulkObservable({time: 500,- ngZone: this.ngZone,notifierObservable: this.existsSubject,bulkGet: this.doSubscriptionsExist.bind(this)}),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.tsindex 76835b9fca..02632c9eb9 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@@ -2,7 +2,7 @@ import * as debug from 'debug'import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'import { catchError, filter, map, share, switchMap, tap } from 'rxjs/operators'import { HttpClient, HttpParams } from '@angular/common/http'-import { Injectable, NgZone } from '@angular/core'+import { Injectable } from '@angular/core'import { AuthUser, ComponentPaginationLight, RestExtractor, RestService, ServerService } from '@app/core'import { buildBulkObservable, objectToFormData } from '@app/helpers'import { Account, AccountService, VideoChannel, VideoChannelService } from '@app/shared/shared-main'@@ -47,13 +47,11 @@ export class VideoPlaylistService {private authHttp: HttpClient,private serverService: ServerService,private restExtractor: RestExtractor,- private restService: RestService,- private ngZone: NgZone+ private restService: RestService) {this.videoExistsInPlaylistObservable = merge(buildBulkObservable({time: 500,- ngZone: this.ngZone,bulkGet: this.doVideosExistInPlaylist.bind(this),notifierObservable: this.videoExistsInPlaylistNotifier}),