diff options
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/shared/search/search.component.ts | 2 | ||||
-rw-r--r-- | client/src/app/videos/video-watch/video-watch.component.ts | 21 |
2 files changed, 15 insertions, 8 deletions
diff --git a/client/src/app/shared/search/search.component.ts b/client/src/app/shared/search/search.component.ts index e864fbc17..219997e85 100644 --- a/client/src/app/shared/search/search.component.ts +++ b/client/src/app/shared/search/search.component.ts | |||
@@ -28,7 +28,7 @@ export class SearchComponent implements OnInit { | |||
28 | constructor(private searchService: SearchService) {} | 28 | constructor(private searchService: SearchService) {} |
29 | 29 | ||
30 | ngOnInit() { | 30 | ngOnInit() { |
31 | // Subscribe is the search changed | 31 | // Subscribe if the search changed |
32 | // Usually changed by videos list component | 32 | // Usually changed by videos list component |
33 | this.searchService.updateSearch.subscribe( | 33 | this.searchService.updateSearch.subscribe( |
34 | newSearchCriterias => { | 34 | newSearchCriterias => { |
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts index 09255de5d..bc0e3157d 100644 --- a/client/src/app/videos/video-watch/video-watch.component.ts +++ b/client/src/app/videos/video-watch/video-watch.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, ElementRef, OnDestroy, OnInit } from '@angular/core'; | 1 | import { Component, ElementRef, NgZone, OnDestroy, OnInit } from '@angular/core'; |
2 | import { ActivatedRoute } from '@angular/router'; | 2 | import { ActivatedRoute } from '@angular/router'; |
3 | 3 | ||
4 | import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; | 4 | import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe'; |
@@ -31,6 +31,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
31 | 31 | ||
32 | constructor( | 32 | constructor( |
33 | private elementRef: ElementRef, | 33 | private elementRef: ElementRef, |
34 | private ngZone: NgZone, | ||
34 | private route: ActivatedRoute, | 35 | private route: ActivatedRoute, |
35 | private videoService: VideoService, | 36 | private videoService: VideoService, |
36 | private webTorrentService: WebTorrentService | 37 | private webTorrentService: WebTorrentService |
@@ -65,12 +66,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
65 | } | 66 | } |
66 | }); | 67 | }); |
67 | 68 | ||
68 | // Refresh each second | 69 | this.runInProgress(torrent); |
69 | this.torrentInfosInterval = setInterval(() => { | ||
70 | this.downloadSpeed = torrent.downloadSpeed; | ||
71 | this.numPeers = torrent.numPeers; | ||
72 | this.uploadSpeed = torrent.uploadSpeed; | ||
73 | }, 1000); | ||
74 | }); | 70 | }); |
75 | } | 71 | } |
76 | 72 | ||
@@ -99,4 +95,15 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
99 | this.error = true; | 95 | this.error = true; |
100 | console.error('The video load seems to be abnormally long.'); | 96 | console.error('The video load seems to be abnormally long.'); |
101 | } | 97 | } |
98 | |||
99 | private runInProgress(torrent: any) { | ||
100 | // Refresh each second | ||
101 | this.torrentInfosInterval = setInterval(() => { | ||
102 | this.ngZone.run(() => { | ||
103 | this.downloadSpeed = torrent.downloadSpeed; | ||
104 | this.numPeers = torrent.numPeers; | ||
105 | this.uploadSpeed = torrent.uploadSpeed; | ||
106 | }); | ||
107 | }, 1000); | ||
108 | } | ||
102 | } | 109 | } |