]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/video-list/video-miniature.component.ts
Client: check token valitidy at startup
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-list / video-miniature.component.ts
index 398d2db7507a2d4f4f2f6df78e9e99ca5b0488e8..ba47155972a08d2b24cce7290b488b9da3a2342d 100644 (file)
@@ -1,5 +1,8 @@
 import { Component, Input, Output, EventEmitter } from '@angular/core';
 
+import { NotificationsService } from 'angular2-notifications';
+
+import { ConfirmService } from '../../core';
 import { SortField, Video, VideoService } from '../shared';
 import { User } from '../../shared';
 
@@ -18,7 +21,11 @@ export class VideoMiniatureComponent {
 
   hovering = false;
 
-  constructor(private videoService: VideoService) {}
+  constructor(
+    private notificationsService: NotificationsService,
+    private confirmService: ConfirmService,
+    private videoService: VideoService
+  ) {}
 
   displayRemoveIcon() {
     return this.hovering && this.video.isRemovableBy(this.user);
@@ -33,11 +40,16 @@ export class VideoMiniatureComponent {
   }
 
   removeVideo(id: string) {
-    if (confirm('Do you really want to remove this video?')) {
-      this.videoService.removeVideo(id).subscribe(
-        status => this.removed.emit(true),
-        error => alert(error.text)
-      );
-    }
+    this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe(
+      res => {
+        if (res === false) return;
+
+        this.videoService.removeVideo(id).subscribe(
+          status => this.removed.emit(true),
+
+          error => this.notificationsService.error('Error', error.text)
+        );
+      }
+    );
   }
 }