Remove protractor workaround

We don't use it anymore
pull/4468/head
Chocobozzz 2021-10-14 11:50:22 +02:00
parent 37cd44d04f
commit afb7d2d5c6
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
8 changed files with 19 additions and 78 deletions

View File

@ -35,7 +35,7 @@ export class PlayerPage {
// Autoplay is disabled on iOS and Safari
if (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 muted
await browser.execute(`document.querySelector('video').muted = true`)
await this.clickOnPlayButton()
} else if (isAutoplay === false) {

View File

@ -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: Socket
constructor (
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)
})
}
}

View File

@ -3,4 +3,3 @@ export * from './constants'
export * from './i18n-utils'
export * from './rxjs'
export * from './utils'
export * from './zone'

View File

@ -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: NgZone
notifierObservable: Observable<T>
time: number
bulkGet: (params: T[]) => Observable<R>
}) {
const { ngZone, notifierObservable, time, bulkGet } = options
const { notifierObservable, time, bulkGet } = options
return 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()
)

View File

@ -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)
}

View File

@ -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()
})
}

View File

@ -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)
}),

View File

@ -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
}),