diff options
Diffstat (limited to 'client/angular/videos/components/watch/videos-watch.component.ts')
-rw-r--r-- | client/angular/videos/components/watch/videos-watch.component.ts | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/client/angular/videos/components/watch/videos-watch.component.ts b/client/angular/videos/components/watch/videos-watch.component.ts index e3a973820..da7f942db 100644 --- a/client/angular/videos/components/watch/videos-watch.component.ts +++ b/client/angular/videos/components/watch/videos-watch.component.ts | |||
@@ -1,8 +1,9 @@ | |||
1 | /// <reference path='../../../../typings/browser/ambient/webtorrent/webtorrent.d.ts' /> | 1 | /// <reference path='../../../../typings/browser/ambient/webtorrent/webtorrent.d.ts' /> |
2 | 2 | ||
3 | import { Component, OnInit, ElementRef } from 'angular2/core'; | 3 | import { Component, OnInit, ElementRef } from 'angular2/core'; |
4 | import { RouteParams } from 'angular2/router'; | 4 | import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router'; |
5 | 5 | ||
6 | // TODO import it with systemjs | ||
6 | declare var WebTorrent: any; | 7 | declare var WebTorrent: any; |
7 | 8 | ||
8 | import { Video } from '../../models/video'; | 9 | import { Video } from '../../models/video'; |
@@ -14,7 +15,7 @@ import { VideosService } from '../../services/videos.service'; | |||
14 | styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ] | 15 | styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ] |
15 | }) | 16 | }) |
16 | 17 | ||
17 | export class VideosWatchComponent { | 18 | export class VideosWatchComponent implements OnInit, CanDeactivate { |
18 | video: Video; | 19 | video: Video; |
19 | 20 | ||
20 | private client: any; | 21 | private client: any; |
@@ -24,6 +25,7 @@ export class VideosWatchComponent { | |||
24 | private _routeParams: RouteParams, | 25 | private _routeParams: RouteParams, |
25 | private _elementRef: ElementRef | 26 | private _elementRef: ElementRef |
26 | ) { | 27 | ) { |
28 | // TODO: use a service | ||
27 | this.client = new WebTorrent({ dht: false }); | 29 | this.client = new WebTorrent({ dht: false }); |
28 | } | 30 | } |
29 | 31 | ||
@@ -47,4 +49,10 @@ export class VideosWatchComponent { | |||
47 | }) | 49 | }) |
48 | }) | 50 | }) |
49 | } | 51 | } |
52 | |||
53 | routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any { | ||
54 | console.log('Removing video from webtorrent.'); | ||
55 | this.client.remove(this.video.magnetUri); | ||
56 | return true; | ||
57 | } | ||
50 | } | 58 | } |