diff options
author | Chocobozzz <me@florianbigard.com> | 2022-07-27 13:44:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-07-27 13:52:13 +0200 |
commit | e3d6c6434f570f77c0532f86c82f78bcafb399ec (patch) | |
tree | 65d525f42c8cf55aba871093b3dd65964f5cd967 /client/src/app/shared/shared-instance | |
parent | 073deef8862f462de5f159a57877ef415ebe4c69 (diff) | |
download | PeerTube-e3d6c6434f570f77c0532f86c82f78bcafb399ec.tar.gz PeerTube-e3d6c6434f570f77c0532f86c82f78bcafb399ec.tar.zst PeerTube-e3d6c6434f570f77c0532f86c82f78bcafb399ec.zip |
Add bulk action on following/followers
Diffstat (limited to 'client/src/app/shared/shared-instance')
-rw-r--r-- | client/src/app/shared/shared-instance/instance-follow.service.ts | 69 |
1 files changed, 51 insertions, 18 deletions
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 06484d938..5366fd068 100644 --- a/client/src/app/shared/shared-instance/instance-follow.service.ts +++ b/client/src/app/shared/shared-instance/instance-follow.service.ts | |||
@@ -1,9 +1,10 @@ | |||
1 | import { SortMeta } from 'primeng/api' | 1 | import { SortMeta } from 'primeng/api' |
2 | import { Observable } from 'rxjs' | 2 | import { from, Observable } from 'rxjs' |
3 | import { catchError, map } from 'rxjs/operators' | 3 | import { catchError, concatMap, map, toArray } from 'rxjs/operators' |
4 | import { HttpClient, HttpParams } from '@angular/common/http' | 4 | import { HttpClient, HttpParams } from '@angular/common/http' |
5 | import { Injectable } from '@angular/core' | 5 | import { Injectable } from '@angular/core' |
6 | import { RestExtractor, RestPagination, RestService } from '@app/core' | 6 | import { RestExtractor, RestPagination, RestService } from '@app/core' |
7 | import { arrayify } from '@shared/core-utils' | ||
7 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' | 8 | import { ActivityPubActorType, ActorFollow, FollowState, ResultList, ServerFollowCreate } from '@shared/models' |
8 | import { environment } from '../../../environments/environment' | 9 | import { environment } from '../../../environments/environment' |
9 | import { AdvancedInputFilter } from '../shared-forms' | 10 | import { AdvancedInputFilter } from '../shared-forms' |
@@ -81,32 +82,64 @@ export class InstanceFollowService { | |||
81 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 82 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
82 | } | 83 | } |
83 | 84 | ||
84 | unfollow (follow: ActorFollow) { | 85 | unfollow (followsArg: ActorFollow[] | ActorFollow) { |
85 | const handle = follow.following.name + '@' + follow.following.host | 86 | const follows = arrayify(followsArg) |
86 | 87 | ||
87 | return this.authHttp.delete(InstanceFollowService.BASE_APPLICATION_URL + '/following/' + handle) | 88 | return from(follows) |
88 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 89 | .pipe( |
90 | concatMap(follow => { | ||
91 | const handle = follow.following.name + '@' + follow.following.host | ||
92 | |||
93 | return this.authHttp.delete(InstanceFollowService.BASE_APPLICATION_URL + '/following/' + handle) | ||
94 | }), | ||
95 | toArray(), | ||
96 | catchError(err => this.restExtractor.handleError(err)) | ||
97 | ) | ||
89 | } | 98 | } |
90 | 99 | ||
91 | acceptFollower (follow: ActorFollow) { | 100 | acceptFollower (followsArg: ActorFollow[] | ActorFollow) { |
92 | const handle = follow.follower.name + '@' + follow.follower.host | 101 | const follows = arrayify(followsArg) |
93 | 102 | ||
94 | return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/accept`, {}) | 103 | return from(follows) |
95 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 104 | .pipe( |
105 | concatMap(follow => { | ||
106 | const handle = follow.follower.name + '@' + follow.follower.host | ||
107 | |||
108 | return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/accept`, {}) | ||
109 | }), | ||
110 | toArray(), | ||
111 | catchError(err => this.restExtractor.handleError(err)) | ||
112 | ) | ||
96 | } | 113 | } |
97 | 114 | ||
98 | rejectFollower (follow: ActorFollow) { | 115 | rejectFollower (followsArg: ActorFollow[] | ActorFollow) { |
99 | const handle = follow.follower.name + '@' + follow.follower.host | 116 | const follows = arrayify(followsArg) |
100 | 117 | ||
101 | return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/reject`, {}) | 118 | return from(follows) |
102 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 119 | .pipe( |
120 | concatMap(follow => { | ||
121 | const handle = follow.follower.name + '@' + follow.follower.host | ||
122 | |||
123 | return this.authHttp.post(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}/reject`, {}) | ||
124 | }), | ||
125 | toArray(), | ||
126 | catchError(err => this.restExtractor.handleError(err)) | ||
127 | ) | ||
103 | } | 128 | } |
104 | 129 | ||
105 | removeFollower (follow: ActorFollow) { | 130 | removeFollower (followsArg: ActorFollow[] | ActorFollow) { |
106 | const handle = follow.follower.name + '@' + follow.follower.host | 131 | const follows = arrayify(followsArg) |
107 | 132 | ||
108 | return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`) | 133 | return from(follows) |
109 | .pipe(catchError(res => this.restExtractor.handleError(res))) | 134 | .pipe( |
135 | concatMap(follow => { | ||
136 | const handle = follow.follower.name + '@' + follow.follower.host | ||
137 | |||
138 | return this.authHttp.delete(`${InstanceFollowService.BASE_APPLICATION_URL}/followers/${handle}`) | ||
139 | }), | ||
140 | toArray(), | ||
141 | catchError(err => this.restExtractor.handleError(err)) | ||
142 | ) | ||
110 | } | 143 | } |
111 | 144 | ||
112 | buildFollowsListFilters (): AdvancedInputFilter[] { | 145 | buildFollowsListFilters (): AdvancedInputFilter[] { |