]> 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 bf66d3ff1083824cf64d34110c9f0359f8df1d26..88c4800ee74be25da096aee52e5f780c19fbef21 100644 (file)
@@ -4,8 +4,8 @@ import { Friend, FriendService } from '../shared';
 
 @Component({
   selector: 'my-friend-list',
-  template: require('./friend-list.component.html'),
-  styles: [ require('./friend-list.component.scss') ]
+  templateUrl: './friend-list.component.html',
+  styleUrls: [ './friend-list.component.scss' ]
 })
 export class FriendListComponent implements OnInit {
   friends: Friend[];
@@ -13,24 +13,7 @@ export class FriendListComponent implements OnInit {
   constructor(private friendService: FriendService) {  }
 
   ngOnInit() {
-    this.friendService.getFriends().subscribe(
-      friends => this.friends = friends,
-
-      err => alert(err)
-    );
-  }
-
-  makeFriends() {
-    this.friendService.makeFriends().subscribe(
-      status => {
-        if (status === 409) {
-          alert('Already made friends!');
-        } else {
-          alert('Made friends!');
-        }
-      },
-      error => alert(error)
-    );
+    this.getFriends();
   }
 
   quitFriends() {
@@ -39,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)
     );
   }
 }