]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/follows/following-list/following-list.component.ts
Add confirm when admin use custom js/css
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / follows / following-list / following-list.component.ts
index a1dff1db3cef288ca4ebb99903a05e24a7bda65d..ad1bd453674862d6352b98350b897eb07405ad92 100644 (file)
@@ -1,7 +1,8 @@
 import { Component } from '@angular/core'
 import { NotificationsService } from 'angular2-notifications'
 import { SortMeta } from 'primeng/primeng'
-import { AccountFollow } from '../../../../../../shared/models/accounts/follow.model'
+import { AccountFollow } from '../../../../../../shared/models/actors/follow.model'
+import { ConfirmService } from '../../../core/confirm/confirm.service'
 import { RestPagination, RestTable } from '../../../shared'
 import { FollowService } from '../shared'
 
@@ -18,11 +19,26 @@ export class FollowingListComponent extends RestTable {
 
   constructor (
     private notificationsService: NotificationsService,
+    private confirmService: ConfirmService,
     private followService: FollowService
   ) {
     super()
   }
 
+  async removeFollowing (follow: AccountFollow) {
+    const res = await this.confirmService.confirm(`Do you really want to unfollow ${follow.following.host}?`, 'Unfollow')
+    if (res === false) return
+
+    this.followService.unfollow(follow).subscribe(
+      () => {
+        this.notificationsService.success('Success', `You are not following ${follow.following.host} anymore.`)
+        this.loadData()
+      },
+
+      err => this.notificationsService.error('Error', err.message)
+    )
+  }
+
   protected loadData () {
     this.followService.getFollowing(this.pagination, this.sort)
                       .subscribe(