X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fcore%2Fnotification%2Fpeertube-socket.service.ts;h=0db86d8e7fd71e3217682f77a2bfe82f95db0465;hb=afb7d2d5c6ca09d2c678781ae4dd3f527604c1b4;hp=bc3f7b89374093c986f4c93314158f3b37466c0f;hpb=dc1f314efdae14f838c109ebbc1e8d69273d0319;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/core/notification/peertube-socket.service.ts b/client/src/app/core/notification/peertube-socket.service.ts index bc3f7b893..0db86d8e7 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: Socket constructor ( - private auth: AuthService, - private ngZone: NgZone + private auth: AuthService ) {} async getMyNotificationsSocket () { @@ -38,7 +37,7 @@ export class PeerTubeSocket { this.liveVideosSocket.emit('subscribe', { videoId }) } - async unsubscribeLiveVideos (videoId: number) { + unsubscribeLiveVideos (videoId: number) { if (!this.liveVideosSocket) return this.liveVideosSocket.emit('unsubscribe', { videoId }) @@ -53,17 +52,13 @@ 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.on('new-notification', (n: UserNotificationServer) => { - this.ngZone.run(() => this.dispatchNotificationEvent('new', n)) - }) + this.notificationSocket = this.io(environment.apiUrl + '/user-notifications', { + query: { accessToken: this.auth.getAccessToken() } }) + this.notificationSocket.on('new-notification', (n: UserNotificationServer) => { + this.dispatchNotificationEvent('new', n) + }) } private async initLiveVideosSocket () { @@ -71,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) }) } }