From 98b01bac2c2c4536aa97d826b61516657f4d15f5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 14 Mar 2016 22:16:43 +0100 Subject: Angular 2 : draft 2 --- .../videos/components/watch/videos-watch.component.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'client/angular/videos/components/watch') 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 @@ /// import { Component, OnInit, ElementRef } from 'angular2/core'; -import { RouteParams } from 'angular2/router'; +import { RouteParams, CanDeactivate, ComponentInstruction } from 'angular2/router'; +// TODO import it with systemjs declare var WebTorrent: any; import { Video } from '../../models/video'; @@ -14,7 +15,7 @@ import { VideosService } from '../../services/videos.service'; styleUrls: [ 'app/angular/videos/components/watch/videos-watch.component.css' ] }) -export class VideosWatchComponent { +export class VideosWatchComponent implements OnInit, CanDeactivate { video: Video; private client: any; @@ -24,6 +25,7 @@ export class VideosWatchComponent { private _routeParams: RouteParams, private _elementRef: ElementRef ) { + // TODO: use a service this.client = new WebTorrent({ dht: false }); } @@ -47,4 +49,10 @@ export class VideosWatchComponent { }) }) } + + routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) : any { + console.log('Removing video from webtorrent.'); + this.client.remove(this.video.magnetUri); + return true; + } } -- cgit v1.2.3