mirror of https://github.com/Chocobozzz/PeerTube
parent
37cd44d04f
commit
afb7d2d5c6
|
@ -35,7 +35,7 @@ export class PlayerPage {
|
||||||
|
|
||||||
// Autoplay is disabled on iOS and Safari
|
// Autoplay is disabled on iOS and Safari
|
||||||
if (isIOS() || isSafari() || isMobileDevice()) {
|
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 browser.execute(`document.querySelector('video').muted = true`)
|
||||||
await this.clickOnPlayButton()
|
await this.clickOnPlayButton()
|
||||||
} else if (isAutoplay === false) {
|
} else if (isAutoplay === false) {
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
import { Subject } from 'rxjs'
|
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 { LiveVideoEventPayload, LiveVideoEventType, UserNotification as UserNotificationServer } from '@shared/models'
|
||||||
import { environment } from '../../../environments/environment'
|
import { environment } from '../../../environments/environment'
|
||||||
import { AuthService } from '../auth'
|
import { AuthService } from '../auth'
|
||||||
import { io, Socket } from 'socket.io-client'
|
|
||||||
|
|
||||||
export type NotificationEvent = 'new' | 'read' | 'read-all'
|
export type NotificationEvent = 'new' | 'read' | 'read-all'
|
||||||
|
|
||||||
|
@ -18,8 +18,7 @@ export class PeerTubeSocket {
|
||||||
private liveVideosSocket: Socket
|
private liveVideosSocket: Socket
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private auth: AuthService,
|
private auth: AuthService
|
||||||
private ngZone: NgZone
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async getMyNotificationsSocket () {
|
async getMyNotificationsSocket () {
|
||||||
|
@ -53,15 +52,12 @@ export class PeerTubeSocket {
|
||||||
|
|
||||||
await this.importIOIfNeeded()
|
await this.importIOIfNeeded()
|
||||||
|
|
||||||
// Prevent protractor issues https://github.com/angular/angular/issues/11853
|
|
||||||
this.ngZone.runOutsideAngular(() => {
|
|
||||||
this.notificationSocket = this.io(environment.apiUrl + '/user-notifications', {
|
this.notificationSocket = this.io(environment.apiUrl + '/user-notifications', {
|
||||||
query: { accessToken: this.auth.getAccessToken() }
|
query: { accessToken: this.auth.getAccessToken() }
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
this.notificationSocket.on('new-notification', (n: UserNotificationServer) => {
|
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()
|
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' ]
|
const types: LiveVideoEventType[] = [ 'views-change', 'state-change' ]
|
||||||
|
|
||||||
for (const type of types) {
|
for (const type of types) {
|
||||||
this.liveVideosSocket.on(type, (payload: LiveVideoEventPayload) => {
|
this.liveVideosSocket.on(type, (payload: LiveVideoEventPayload) => {
|
||||||
this.ngZone.run(() => this.dispatchLiveVideoEvent(type, payload))
|
this.dispatchLiveVideoEvent(type, payload)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,4 +3,3 @@ export * from './constants'
|
||||||
export * from './i18n-utils'
|
export * from './i18n-utils'
|
||||||
export * from './rxjs'
|
export * from './rxjs'
|
||||||
export * from './utils'
|
export * from './utils'
|
||||||
export * from './zone'
|
|
||||||
|
|
|
@ -1,24 +1,19 @@
|
||||||
import { uniq } from 'lodash-es'
|
import { uniq } from 'lodash-es'
|
||||||
import { asyncScheduler, Observable } from 'rxjs'
|
import { Observable } from 'rxjs'
|
||||||
import { bufferTime, distinctUntilChanged, filter, map, observeOn, share, switchMap } from 'rxjs/operators'
|
import { bufferTime, distinctUntilChanged, filter, map, share, switchMap } from 'rxjs/operators'
|
||||||
import { NgZone } from '@angular/core'
|
|
||||||
import { enterZone, leaveZone } from './zone'
|
|
||||||
|
|
||||||
function buildBulkObservable <T extends number | string, R> (options: {
|
function buildBulkObservable <T extends number | string, R> (options: {
|
||||||
ngZone: NgZone
|
|
||||||
notifierObservable: Observable<T>
|
notifierObservable: Observable<T>
|
||||||
time: number
|
time: number
|
||||||
bulkGet: (params: T[]) => Observable<R>
|
bulkGet: (params: T[]) => Observable<R>
|
||||||
}) {
|
}) {
|
||||||
const { ngZone, notifierObservable, time, bulkGet } = options
|
const { notifierObservable, time, bulkGet } = options
|
||||||
|
|
||||||
return notifierObservable.pipe(
|
return notifierObservable.pipe(
|
||||||
distinctUntilChanged(),
|
distinctUntilChanged(),
|
||||||
// We leave Angular zone so Protractor does not get stuck
|
bufferTime(time),
|
||||||
bufferTime(time, leaveZone(ngZone, asyncScheduler)),
|
|
||||||
filter(params => params.length !== 0),
|
filter(params => params.length !== 0),
|
||||||
map(params => uniq(params)),
|
map(params => uniq(params)),
|
||||||
observeOn(enterZone(ngZone, asyncScheduler)),
|
|
||||||
switchMap(params => bulkGet(params)),
|
switchMap(params => bulkGet(params)),
|
||||||
share()
|
share()
|
||||||
)
|
)
|
||||||
|
|
|
@ -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)
|
|
||||||
}
|
|
|
@ -1,7 +1,7 @@
|
||||||
import * as debug from 'debug'
|
import * as debug from 'debug'
|
||||||
import { Observable, Subject } from 'rxjs'
|
import { Observable, Subject } from 'rxjs'
|
||||||
import { first, map } from 'rxjs/operators'
|
import { first, map } from 'rxjs/operators'
|
||||||
import { Injectable, NgZone } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { buildBulkObservable } from '@app/helpers'
|
import { buildBulkObservable } from '@app/helpers'
|
||||||
import { ResultList } from '@shared/models/common'
|
import { ResultList } from '@shared/models/common'
|
||||||
import { Video, VideoChannel } from '../shared-main'
|
import { Video, VideoChannel } from '../shared-main'
|
||||||
|
@ -23,8 +23,7 @@ export class FindInBulkService {
|
||||||
private getPlaylistInBulk: BulkObservables<string, ResultList<VideoPlaylist>>
|
private getPlaylistInBulk: BulkObservables<string, ResultList<VideoPlaylist>>
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private searchService: SearchService,
|
private searchService: SearchService
|
||||||
private ngZone: NgZone
|
|
||||||
) {
|
) {
|
||||||
this.getVideoInBulk = this.buildBulkObservableObject(this.getVideosInBulk.bind(this))
|
this.getVideoInBulk = this.buildBulkObservableObject(this.getVideosInBulk.bind(this))
|
||||||
this.getChannelInBulk = this.buildBulkObservableObject(this.getChannelsInBulk.bind(this))
|
this.getChannelInBulk = this.buildBulkObservableObject(this.getChannelsInBulk.bind(this))
|
||||||
|
@ -115,7 +114,6 @@ export class FindInBulkService {
|
||||||
result: buildBulkObservable({
|
result: buildBulkObservable({
|
||||||
time: 500,
|
time: 500,
|
||||||
bulkGet,
|
bulkGet,
|
||||||
ngZone: this.ngZone,
|
|
||||||
notifierObservable: notifier.asObservable()
|
notifierObservable: notifier.asObservable()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as debug from 'debug'
|
||||||
import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
|
import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
|
||||||
import { catchError, filter, map, switchMap, tap } from 'rxjs/operators'
|
import { catchError, filter, map, switchMap, tap } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
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 { ComponentPaginationLight, RestExtractor, RestService } from '@app/core'
|
||||||
import { buildBulkObservable } from '@app/helpers'
|
import { buildBulkObservable } from '@app/helpers'
|
||||||
import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
|
import { Video, VideoChannel, VideoChannelService, VideoService } from '@app/shared/shared-main'
|
||||||
|
@ -30,13 +30,11 @@ export class UserSubscriptionService {
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private restExtractor: RestExtractor,
|
private restExtractor: RestExtractor,
|
||||||
private videoService: VideoService,
|
private videoService: VideoService,
|
||||||
private restService: RestService,
|
private restService: RestService
|
||||||
private ngZone: NgZone
|
|
||||||
) {
|
) {
|
||||||
this.existsObservable = merge(
|
this.existsObservable = merge(
|
||||||
buildBulkObservable({
|
buildBulkObservable({
|
||||||
time: 500,
|
time: 500,
|
||||||
ngZone: this.ngZone,
|
|
||||||
notifierObservable: this.existsSubject,
|
notifierObservable: this.existsSubject,
|
||||||
bulkGet: this.doSubscriptionsExist.bind(this)
|
bulkGet: this.doSubscriptionsExist.bind(this)
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as debug from 'debug'
|
||||||
import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
|
import { merge, Observable, of, ReplaySubject, Subject } from 'rxjs'
|
||||||
import { catchError, filter, map, share, switchMap, tap } from 'rxjs/operators'
|
import { catchError, filter, map, share, switchMap, tap } from 'rxjs/operators'
|
||||||
import { HttpClient, HttpParams } from '@angular/common/http'
|
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 { AuthUser, ComponentPaginationLight, RestExtractor, RestService, ServerService } from '@app/core'
|
||||||
import { buildBulkObservable, objectToFormData } from '@app/helpers'
|
import { buildBulkObservable, objectToFormData } from '@app/helpers'
|
||||||
import { Account, AccountService, VideoChannel, VideoChannelService } from '@app/shared/shared-main'
|
import { Account, AccountService, VideoChannel, VideoChannelService } from '@app/shared/shared-main'
|
||||||
|
@ -47,13 +47,11 @@ export class VideoPlaylistService {
|
||||||
private authHttp: HttpClient,
|
private authHttp: HttpClient,
|
||||||
private serverService: ServerService,
|
private serverService: ServerService,
|
||||||
private restExtractor: RestExtractor,
|
private restExtractor: RestExtractor,
|
||||||
private restService: RestService,
|
private restService: RestService
|
||||||
private ngZone: NgZone
|
|
||||||
) {
|
) {
|
||||||
this.videoExistsInPlaylistObservable = merge(
|
this.videoExistsInPlaylistObservable = merge(
|
||||||
buildBulkObservable({
|
buildBulkObservable({
|
||||||
time: 500,
|
time: 500,
|
||||||
ngZone: this.ngZone,
|
|
||||||
bulkGet: this.doVideosExistInPlaylist.bind(this),
|
bulkGet: this.doVideosExistInPlaylist.bind(this),
|
||||||
notifierObservable: this.videoExistsInPlaylistNotifier
|
notifierObservable: this.videoExistsInPlaylistNotifier
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in New Issue