From b8f4167fb6fa448125aeecff80b201d74e27fe6a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 28 Nov 2019 11:37:32 +0100 Subject: Only display accepted followers/followings in about page --- .../about-follows/about-follows.component.ts | 4 ++-- .../followers-list/followers-list.component.ts | 2 +- .../following-list/following-list.component.ts | 2 +- client/src/app/shared/instance/follow.service.ts | 22 +++++++++++++++++++--- 4 files changed, 23 insertions(+), 7 deletions(-) (limited to 'client') diff --git a/client/src/app/+about/about-follows/about-follows.component.ts b/client/src/app/+about/about-follows/about-follows.component.ts index d60307928..fc265fecb 100644 --- a/client/src/app/+about/about-follows/about-follows.component.ts +++ b/client/src/app/+about/about-follows/about-follows.component.ts @@ -74,7 +74,7 @@ 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) @@ -92,7 +92,7 @@ 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) diff --git a/client/src/app/+admin/follows/followers-list/followers-list.component.ts b/client/src/app/+admin/follows/followers-list/followers-list.component.ts index eb3137e26..707daef84 100644 --- a/client/src/app/+admin/follows/followers-list/followers-list.component.ts +++ b/client/src/app/+admin/follows/followers-list/followers-list.component.ts @@ -88,7 +88,7 @@ export class FollowersListComponent extends RestTable implements OnInit { } protected loadData () { - this.followService.getFollowers(this.pagination, this.sort, this.search) + this.followService.getFollowers({ pagination: this.pagination, sort: this.sort, search: this.search }) .subscribe( resultList => { this.followers = resultList.data diff --git a/client/src/app/+admin/follows/following-list/following-list.component.ts b/client/src/app/+admin/follows/following-list/following-list.component.ts index b97923f04..3d78c254f 100644 --- a/client/src/app/+admin/follows/following-list/following-list.component.ts +++ b/client/src/app/+admin/follows/following-list/following-list.component.ts @@ -50,7 +50,7 @@ export class FollowingListComponent extends RestTable implements OnInit { } protected loadData () { - this.followService.getFollowing(this.pagination, this.sort, this.search) + this.followService.getFollowing({ pagination: this.pagination, sort: this.sort, search: this.search }) .subscribe( resultList => { this.following = resultList.data diff --git a/client/src/app/shared/instance/follow.service.ts b/client/src/app/shared/instance/follow.service.ts index 63f9e2687..1477a26ae 100644 --- a/client/src/app/shared/instance/follow.service.ts +++ b/client/src/app/shared/instance/follow.service.ts @@ -2,7 +2,7 @@ import { catchError, map } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { Observable } from 'rxjs' -import { ActorFollow, ResultList } from '@shared/index' +import { ActorFollow, FollowState, ResultList } from '@shared/index' import { environment } from '../../../environments/environment' import { RestExtractor, RestPagination, RestService } from '../rest' import { SortMeta } from 'primeng/api' @@ -18,11 +18,19 @@ export class FollowService { ) { } - getFollowing (pagination: RestPagination, sort: SortMeta, search?: string): Observable> { + getFollowing (options: { + pagination: RestPagination, + sort: SortMeta, + search?: string, + state?: FollowState + }): Observable> { + const { pagination, sort, search, state } = options + let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) if (search) params = params.append('search', search) + if (state) params = params.append('state', state) return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/following', { params }) .pipe( @@ -31,11 +39,19 @@ export class FollowService { ) } - getFollowers (pagination: RestPagination, sort: SortMeta, search?: string): Observable> { + getFollowers (options: { + pagination: RestPagination, + sort: SortMeta, + search?: string, + state?: FollowState + }): Observable> { + const { pagination, sort, search, state } = options + let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) if (search) params = params.append('search', search) + if (state) params = params.append('state', state) return this.authHttp.get>(FollowService.BASE_APPLICATION_URL + '/followers', { params }) .pipe( -- cgit v1.2.3