From 073deef8862f462de5f159a57877ef415ebe4c69 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Jul 2022 11:05:32 +0200 Subject: Handle rejected follows in client Also add quick filters so it's easier to find pending follows --- .../shared-instance/instance-follow.service.ts | 41 ++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-instance/instance-follow.service.ts b/client/src/app/shared/shared-instance/instance-follow.service.ts index a83f7c4ad..06484d938 100644 --- a/client/src/app/shared/shared-instance/instance-follow.service.ts +++ b/client/src/app/shared/shared-instance/instance-follow.service.ts @@ -6,6 +6,7 @@ import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' import { environment } from '../../../environments/environment' +import { AdvancedInputFilter } from '../shared-forms' @Injectable() export class InstanceFollowService { @@ -30,7 +31,10 @@ export class InstanceFollowService { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) - if (search) params = params.append('search', search) + if (search) { + params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search)) + } + if (state) params = params.append('state', state) if (actorType) params = params.append('actorType', actorType) @@ -53,7 +57,10 @@ export class InstanceFollowService { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) - if (search) params = params.append('search', search) + if (search) { + params = this.restService.addObjectParams(params, this.parseFollowsListFilters(search)) + } + if (state) params = params.append('state', state) if (actorType) params = params.append('actorType', actorType) @@ -101,4 +108,34 @@ export class InstanceFollowService { return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`) .pipe(catchError(res => this.restExtractor.handleError(res))) } + + buildFollowsListFilters (): AdvancedInputFilter[] { + return [ + { + title: $localize`Advanced filters`, + children: [ + { + value: 'state:accepted', + label: $localize`Accepted follows` + }, + { + value: 'state:rejected', + label: $localize`Rejected follows` + }, + { + value: 'state:pending', + label: $localize`Pending follows` + } + ] + } + ] + } + + private parseFollowsListFilters (search: string) { + return this.restService.parseQueryStringFilter(search, { + state: { + prefix: 'state:' + } + }) + } } -- cgit v1.2.3