From a282e4d8a072cd56db8c393be7715bda420a243d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Mon, 28 Feb 2022 10:41:23 +0100 Subject: Continue user mute in ban modal PR --- .../app/shared/shared-main/account/actor.model.ts | 8 ++-- .../shared/shared-moderation/blocklist.service.ts | 15 ++++--- .../user-ban-modal.component.html | 17 ++++---- .../user-ban-modal.component.scss | 5 +++ .../shared-moderation/user-ban-modal.component.ts | 41 +++++++++---------- .../user-moderation-dropdown.component.ts | 46 +++++++++++++++------- 6 files changed, 79 insertions(+), 53 deletions(-) (limited to 'client/src/app/shared') diff --git a/client/src/app/shared/shared-main/account/actor.model.ts b/client/src/app/shared/shared-main/account/actor.model.ts index a54f51aa4..bd693860d 100644 --- a/client/src/app/shared/shared-main/account/actor.model.ts +++ b/client/src/app/shared/shared-main/account/actor.model.ts @@ -1,4 +1,4 @@ -import { getAbsoluteAPIUrl } from '@app/helpers' +import { getAbsoluteAPIUrl, getAPIHost } from '@app/helpers' import { Actor as ServerActor, ActorImage } from '@shared/models' export abstract class Actor implements ServerActor { @@ -32,8 +32,7 @@ export abstract class Actor implements ServerActor { } static CREATE_BY_STRING (accountName: string, host: string, forceHostname = false) { - const absoluteAPIUrl = getAbsoluteAPIUrl() - const thisHost = new URL(absoluteAPIUrl).host + const thisHost = getAPIHost() if (host.trim() === thisHost && !forceHostname) return accountName @@ -41,8 +40,7 @@ export abstract class Actor implements ServerActor { } static IS_LOCAL (host: string) { - const absoluteAPIUrl = getAbsoluteAPIUrl() - const thisHost = new URL(absoluteAPIUrl).host + const thisHost = getAPIHost() return host.trim() === thisHost } diff --git a/client/src/app/shared/shared-moderation/blocklist.service.ts b/client/src/app/shared/shared-moderation/blocklist.service.ts index f4836c6c4..3e92c2831 100644 --- a/client/src/app/shared/shared-moderation/blocklist.service.ts +++ b/client/src/app/shared/shared-moderation/blocklist.service.ts @@ -1,5 +1,6 @@ import { SortMeta } from 'primeng/api' -import { catchError, map } from 'rxjs/operators' +import { from } from 'rxjs' +import { catchError, concatMap, map, toArray } from 'rxjs/operators' import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import { RestExtractor, RestPagination, RestService } from '@app/core' @@ -120,11 +121,15 @@ export class BlocklistService { ) } - blockAccountByInstance (account: Pick) { - const body = { accountName: account.nameWithHost } + blockAccountByInstance (accountsArg: Pick | Pick[]) { + const accounts = Array.isArray(accountsArg) ? accountsArg : [ accountsArg ] - return this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', body) - .pipe(catchError(err => this.restExtractor.handleError(err))) + return from(accounts) + .pipe( + concatMap(a => this.authHttp.post(BlocklistService.BASE_SERVER_BLOCKLIST_URL + '/accounts', { accountName: a.nameWithHost })), + toArray(), + catchError(err => this.restExtractor.handleError(err)) + ) } unblockAccountByInstance (account: Pick) { diff --git a/client/src/app/shared/shared-moderation/user-ban-modal.component.html b/client/src/app/shared/shared-moderation/user-ban-modal.component.html index 6c83cc9cc..2b6726bdc 100644 --- a/client/src/app/shared/shared-moderation/user-ban-modal.component.html +++ b/client/src/app/shared/shared-moderation/user-ban-modal.component.html @@ -1,11 +1,15 @@