import { Component, ElementRef, OnInit } from '@angular/core';
-import { CanDeactivate, ComponentInstruction, RouteParams } from '@angular/router-deprecated';
+import { CanDeactivate, RouteSegment } from '@angular/router';
import { BytesPipe } from 'angular-pipes/src/math/bytes.pipe';
constructor(
private elementRef: ElementRef,
- private routeParams: RouteParams,
+ private routeSegment: RouteSegment,
private videoService: VideoService,
private webTorrentService: WebTorrentService
) {}
}
ngOnInit() {
- let id = this.routeParams.get('id');
+ let id = this.routeSegment.getParam('id');
this.videoService.getVideo(id).subscribe(
video => {
this.video = video;
);
}
- routerCanDeactivate(next: ComponentInstruction, prev: ComponentInstruction) {
+ routerCanDeactivate() {
console.log('Removing video from webtorrent.');
clearInterval(this.torrentInfosInterval);
this.webTorrentService.remove(this.video.magnetUri);
- return true;
+ return Promise.resolve(true);
}
private loadTooLong() {