]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/core/notification/peertube-socket.service.ts
Allow configuration to be static/readonly (#4315)
[github/Chocobozzz/PeerTube.git] / client / src / app / core / notification / peertube-socket.service.ts
index 7e1c43364a7d0b1190ae2dfa5a7d9a4b90b197da..50d5df68f49853ae33ea4b7be8369fce3c359f42 100644 (file)
@@ -38,7 +38,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 })
@@ -60,7 +60,9 @@ export class PeerTubeSocket {
       })
     })
 
-    this.notificationSocket.on('new-notification', (n: UserNotificationServer) => this.dispatchNotificationEvent('new', n))
+    this.notificationSocket.on('new-notification', (n: UserNotificationServer) => {
+      this.ngZone.run(() => this.dispatchNotificationEvent('new', n))
+    })
   }
 
   private async initLiveVideosSocket () {
@@ -73,8 +75,13 @@ export class PeerTubeSocket {
       this.liveVideosSocket = this.io(environment.apiUrl + '/live-videos')
     })
 
-    const type: LiveVideoEventType = 'state-change'
-    this.liveVideosSocket.on(type, (payload: LiveVideoEventPayload) => this.dispatchLiveVideoEvent(type, payload))
+    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))
+      })
+    }
   }
 
   private async importIOIfNeeded () {