]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/admin/friends/friend-list/friend-list.component.ts
Client: fix error alert
[github/Chocobozzz/PeerTube.git] / client / src / app / admin / friends / friend-list / friend-list.component.ts
index 379d44c975a5d83055577267cab1e214a9d1ec7c..88c4800ee74be25da096aee52e5f780c19fbef21 100644 (file)
@@ -1,13 +1,11 @@
 import { Component, OnInit } from '@angular/core';
-import { ROUTER_DIRECTIVES } from '@angular/router';
 
 import { Friend, FriendService } from '../shared';
 
 @Component({
   selector: 'my-friend-list',
-  template: require('./friend-list.component.html'),
-  styles: [ require('./friend-list.component.scss') ],
-  directives: [ ROUTER_DIRECTIVES ]
+  templateUrl: './friend-list.component.html',
+  styleUrls: [ './friend-list.component.scss' ]
 })
 export class FriendListComponent implements OnInit {
   friends: Friend[];
@@ -15,11 +13,7 @@ export class FriendListComponent implements OnInit {
   constructor(private friendService: FriendService) {  }
 
   ngOnInit() {
-    this.friendService.getFriends().subscribe(
-      friends => this.friends = friends,
-
-      err => alert(err)
-    );
+    this.getFriends();
   }
 
   quitFriends() {
@@ -28,8 +22,17 @@ export class FriendListComponent implements OnInit {
     this.friendService.quitFriends().subscribe(
       status => {
         alert('Quit friends!');
+        this.getFriends();
       },
-      error => alert(error)
+      error => alert(error.text)
+    );
+  }
+
+  private getFriends() {
+    this.friendService.getFriends().subscribe(
+      friends => this.friends = friends,
+
+      err => alert(err.text)
     );
   }
 }