]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+about/about-follows/about-follows.component.ts
Hide generic channel display name and avatar on watch view (#2988)
[github/Chocobozzz/PeerTube.git] / client / src / app / +about / about-follows / about-follows.component.ts
index f0e1375d66e4d5d34256b3c8d63cf4a1a08f613d..17c6903b8ec4a3be7f30e1bd5007ab7594030188 100644 (file)
@@ -1,9 +1,8 @@
-import { Component, OnInit } from '@angular/core'
-import { FollowService } from '@app/shared/instance/follow.service'
-import { ComponentPagination, hasMoreItems } from '@app/shared/rest/component-pagination.model'
-import { Notifier } from '@app/core'
-import { RestService } from '@app/shared'
 import { SortMeta } from 'primeng/api'
+import { Subject } from 'rxjs'
+import { Component, OnInit } from '@angular/core'
+import { ComponentPagination, hasMoreItems, Notifier, RestService } from '@app/core'
+import { InstanceFollowService } from '@app/shared/shared-instance'
 
 @Component({
   selector: 'my-about-follows',
@@ -17,13 +16,13 @@ export class AboutFollowsComponent implements OnInit {
 
   followersPagination: ComponentPagination = {
     currentPage: 1,
-    itemsPerPage: 40,
+    itemsPerPage: 20,
     totalItems: null
   }
 
   followingsPagination: ComponentPagination = {
     currentPage: 1,
-    itemsPerPage: 40,
+    itemsPerPage: 20,
     totalItems: null
   }
 
@@ -32,10 +31,12 @@ export class AboutFollowsComponent implements OnInit {
     order: -1
   }
 
+  onDataSubject = new Subject<any[]>()
+
   constructor (
     private restService: RestService,
     private notifier: Notifier,
-    private followService: FollowService
+    private followService: InstanceFollowService
   ) { }
 
   ngOnInit () {
@@ -71,13 +72,15 @@ export class AboutFollowsComponent implements OnInit {
   private loadMoreFollowers () {
     const pagination = this.restService.componentPaginationToRestPagination(this.followersPagination)
 
-    this.followService.getFollowers(pagination, this.sort)
+    this.followService.getFollowers({ pagination: pagination, sort: this.sort, state: 'accepted' })
         .subscribe(
           resultList => {
             const newFollowers = resultList.data.map(r => r.follower.host)
             this.followers = this.followers.concat(newFollowers)
 
             this.followersPagination.totalItems = resultList.total
+
+            this.onDataSubject.next(newFollowers)
           },
 
           err => this.notifier.error(err.message)
@@ -87,13 +90,15 @@ export class AboutFollowsComponent implements OnInit {
   private loadMoreFollowings () {
     const pagination = this.restService.componentPaginationToRestPagination(this.followingsPagination)
 
-    this.followService.getFollowing(pagination, this.sort)
+    this.followService.getFollowing({ pagination, sort: this.sort, state: 'accepted' })
         .subscribe(
           resultList => {
             const newFollowings = resultList.data.map(r => r.following.host)
             this.followings = this.followings.concat(newFollowings)
 
             this.followingsPagination.totalItems = resultList.total
+
+            this.onDataSubject.next(newFollowings)
           },
 
           err => this.notifier.error(err.message)