diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-27 11:30:36 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-27 11:30:36 +0100 |
commit | 0d4fb7e6d482635cd725cd2f09cf981f82cbd92c (patch) | |
tree | 76462b107c083d7cf8695df13687108396f4c39d | |
parent | 9a5d2a3f54fbc4ef899988dd85cf65f92cc3ffff (diff) | |
download | PeerTube-0d4fb7e6d482635cd725cd2f09cf981f82cbd92c.tar.gz PeerTube-0d4fb7e6d482635cd725cd2f09cf981f82cbd92c.tar.zst PeerTube-0d4fb7e6d482635cd725cd2f09cf981f82cbd92c.zip |
Client: fix video timeout
-rw-r--r-- | client/src/app/videos/video-watch/video-watch.component.ts | 17 |
1 files changed, 8 insertions, 9 deletions
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 d83cc5a7a..5cd7550be 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,3 @@ | |||
1 | import { setInterval, setTimeout } from 'timers' | ||
2 | import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; | 1 | import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; |
3 | import { ActivatedRoute } from '@angular/router'; | 2 | import { ActivatedRoute } from '@angular/router'; |
4 | 3 | ||
@@ -19,7 +18,7 @@ import { WebTorrentService } from './webtorrent.service'; | |||
19 | }) | 18 | }) |
20 | 19 | ||
21 | export class VideoWatchComponent implements OnInit, OnDestroy { | 20 | export class VideoWatchComponent implements OnInit, OnDestroy { |
22 | private static LOADTIME_TOO_LONG: number = 30000; | 21 | private static LOADTIME_TOO_LONG: number = 20000; |
23 | 22 | ||
24 | @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent; | 23 | @ViewChild('videoMagnetModal') videoMagnetModal: VideoMagnetComponent; |
25 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent; | 24 | @ViewChild('videoShareModal') videoShareModal: VideoShareComponent; |
@@ -35,9 +34,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
35 | video: Video = null; | 34 | video: Video = null; |
36 | videoNotFound = false; | 35 | videoNotFound = false; |
37 | 36 | ||
38 | private errorTimer: NodeJS.Timer; | 37 | private errorTimer: number; |
39 | private sub: any; | 38 | private sub: any; |
40 | private torrentInfosInterval: NodeJS.Timer; | 39 | private torrentInfosInterval: number; |
41 | 40 | ||
42 | constructor( | 41 | constructor( |
43 | private elementRef: ElementRef, | 42 | private elementRef: ElementRef, |
@@ -80,8 +79,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
80 | ngOnDestroy() { | 79 | ngOnDestroy() { |
81 | // Remove WebTorrent stuff | 80 | // Remove WebTorrent stuff |
82 | console.log('Removing video from webtorrent.'); | 81 | console.log('Removing video from webtorrent.'); |
83 | clearInterval(this.torrentInfosInterval); | 82 | window.clearInterval(this.torrentInfosInterval); |
84 | clearTimeout(this.errorTimer); | 83 | window.clearTimeout(this.errorTimer); |
85 | 84 | ||
86 | if (this.video !== null) { | 85 | if (this.video !== null) { |
87 | this.webTorrentService.remove(this.video.magnetUri); | 86 | this.webTorrentService.remove(this.video.magnetUri); |
@@ -104,11 +103,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
104 | 103 | ||
105 | // The callback might never return if there are network issues | 104 | // The callback might never return if there are network issues |
106 | // So we create a timer to inform the user the load is abnormally long | 105 | // So we create a timer to inform the user the load is abnormally long |
107 | this.errorTimer = setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG); | 106 | this.errorTimer = window.setTimeout(() => this.loadTooLong(), VideoWatchComponent.LOADTIME_TOO_LONG); |
108 | 107 | ||
109 | this.webTorrentService.add(this.video.magnetUri, (torrent) => { | 108 | this.webTorrentService.add(this.video.magnetUri, (torrent) => { |
110 | // Clear the error timer | 109 | // Clear the error timer |
111 | clearTimeout(this.errorTimer); | 110 | window.clearTimeout(this.errorTimer); |
112 | // Maybe the error was fired by the timer, so reset it | 111 | // Maybe the error was fired by the timer, so reset it |
113 | this.error = false; | 112 | this.error = false; |
114 | 113 | ||
@@ -170,7 +169,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
170 | 169 | ||
171 | private runInProgress(torrent: any) { | 170 | private runInProgress(torrent: any) { |
172 | // Refresh each second | 171 | // Refresh each second |
173 | this.torrentInfosInterval = setInterval(() => { | 172 | this.torrentInfosInterval = window.setInterval(() => { |
174 | this.ngZone.run(() => { | 173 | this.ngZone.run(() => { |
175 | this.downloadSpeed = torrent.downloadSpeed; | 174 | this.downloadSpeed = torrent.downloadSpeed; |
176 | this.numPeers = torrent.numPeers; | 175 | this.numPeers = torrent.numPeers; |