]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix socket io with angular
authorChocobozzz <me@florianbigard.com>
Thu, 10 Dec 2020 09:20:04 +0000 (10:20 +0100)
committerChocobozzz <me@florianbigard.com>
Thu, 10 Dec 2020 09:20:04 +0000 (10:20 +0100)
client/src/app/+videos/+video-watch/video-watch.component.html
client/src/app/core/notification/peertube-socket.service.ts

index 9cabe3bbc327c2ebacdd62da5c418671ddb7ee6e..669fede439b34d0a9cda434f0a9d6dc97c088039 100644 (file)
             <div class="video-info-first-row-bottom">
               <div class="d-none d-md-block video-info-date-views">
                 <ng-container i18n>Published <my-date-toggle [date]="video.publishedAt"></my-date-toggle></ng-container>
-
-                <span i18n [title]="video.getExactNumberOfViews()" class="views">
-                  • {{ video.views | myNumberFormatter }}
-                  <ng-container *ngIf="!video.isLive">views</ng-container>
-                  <ng-container *ngIf="video.isLive">viewers</ng-container>
-                </span>
+                •
+                <my-video-views-counter [video]="video"></my-video-views-counter>
               </div>
 
               <div class="video-actions-rates">
index 089276cfcf7619ca7a15da01dc3046a6454ecfaf..bc3f7b89374093c986f4c93314158f3b37466c0f 100644 (file)
@@ -58,9 +58,12 @@ export class PeerTubeSocket {
       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.on('new-notification', (n: UserNotificationServer) => this.dispatchNotificationEvent('new', n))
   }
 
   private async initLiveVideosSocket () {
@@ -76,7 +79,9 @@ export class PeerTubeSocket {
     const types: LiveVideoEventType[] = [ 'views-change', 'state-change' ]
 
     for (const type of types) {
-      this.liveVideosSocket.on(type, (payload: LiveVideoEventPayload) => this.dispatchLiveVideoEvent(type, payload))
+      this.liveVideosSocket.on(type, (payload: LiveVideoEventPayload) => {
+        this.ngZone.run(() => this.dispatchLiveVideoEvent(type, payload))
+      })
     }
   }