]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/admin/friends/friend-list/friend-list.component.ts
Client: refresh friends list after quitting them
[github/Chocobozzz/PeerTube.git] / client / src / app / admin / friends / friend-list / friend-list.component.ts
CommitLineData
e2f555ca 1import { Component, OnInit } from '@angular/core';
e105c19c 2import { ROUTER_DIRECTIVES } from '@angular/router';
e2f555ca
C
3
4import { Friend, FriendService } from '../shared';
5
6@Component({
7 selector: 'my-friend-list',
8 template: require('./friend-list.component.html'),
e105c19c
C
9 styles: [ require('./friend-list.component.scss') ],
10 directives: [ ROUTER_DIRECTIVES ]
e2f555ca
C
11})
12export class FriendListComponent implements OnInit {
13 friends: Friend[];
14
15 constructor(private friendService: FriendService) { }
16
17 ngOnInit() {
93c462b7 18 this.getFriends();
e2f555ca
C
19 }
20
e2f555ca
C
21 quitFriends() {
22 if (!confirm('Are you sure?')) return;
23
24 this.friendService.quitFriends().subscribe(
25 status => {
26 alert('Quit friends!');
93c462b7 27 this.getFriends();
e2f555ca
C
28 },
29 error => alert(error)
30 );
31 }
93c462b7
C
32
33 private getFriends() {
34 this.friendService.getFriends().subscribe(
35 friends => this.friends = friends,
36
37 err => alert(err)
38 );
39 }
e2f555ca 40}