aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
diff options
context:
space:
mode:
authorkontrollanten <6680299+kontrollanten@users.noreply.github.com>2022-07-08 10:57:29 +0200
committerGitHub <noreply@github.com>2022-07-08 10:57:29 +0200
commita28b0f696c1990a3e7a7385e65d8ea910f46be1e (patch)
treedf494c61c20c86ca82a566b88d1987fb8a7ea703 /client/src/app/shared/shared-abuse-list/abuse-details.component.ts
parentf8b4a71d428703811fa74dd811ef715c7d7afff6 (diff)
downloadPeerTube-a28b0f696c1990a3e7a7385e65d8ea910f46be1e.tar.gz
PeerTube-a28b0f696c1990a3e7a7385e65d8ea910f46be1e.tar.zst
PeerTube-a28b0f696c1990a3e7a7385e65d8ea910f46be1e.zip
fix(client/AbuseDetails): infinite update loop (#5109)
* fix(client/AbuseDetails): infinite update loop * Abuse may not have predefined reasons Co-authored-by: Chocobozzz <me@florianbigard.com>
Diffstat (limited to 'client/src/app/shared/shared-abuse-list/abuse-details.component.ts')
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-details.component.ts23
1 files changed, 12 insertions, 11 deletions
diff --git a/client/src/app/shared/shared-abuse-list/abuse-details.component.ts b/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
index 14674c5f0..e15edf8c2 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-details.component.ts
@@ -1,4 +1,4 @@
1import { Component, Input } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { durationToString } from '@app/helpers' 2import { durationToString } from '@app/helpers'
3import { AbusePredefinedReasonsString } from '@shared/models' 3import { AbusePredefinedReasonsString } from '@shared/models'
4import { ProcessedAbuse } from './processed-abuse.model' 4import { ProcessedAbuse } from './processed-abuse.model'
@@ -8,10 +8,11 @@ import { ProcessedAbuse } from './processed-abuse.model'
8 templateUrl: './abuse-details.component.html', 8 templateUrl: './abuse-details.component.html',
9 styleUrls: [ '../shared-moderation/moderation.scss', './abuse-details.component.scss' ] 9 styleUrls: [ '../shared-moderation/moderation.scss', './abuse-details.component.scss' ]
10}) 10})
11export class AbuseDetailsComponent { 11export class AbuseDetailsComponent implements OnInit {
12 @Input() abuse: ProcessedAbuse 12 @Input() abuse: ProcessedAbuse
13 @Input() isAdminView: boolean 13 @Input() isAdminView: boolean
14 14
15 predefinedReasons: { id: string, label: string }[]
15 private predefinedReasonsTranslations: { [key in AbusePredefinedReasonsString]: string } 16 private predefinedReasonsTranslations: { [key in AbusePredefinedReasonsString]: string }
16 17
17 constructor () { 18 constructor () {
@@ -27,6 +28,15 @@ export class AbuseDetailsComponent {
27 } 28 }
28 } 29 }
29 30
31 ngOnInit (): void {
32 if (!this.abuse.predefinedReasons) return
33
34 this.predefinedReasons = this.abuse.predefinedReasons.map(r => ({
35 id: r,
36 label: this.predefinedReasonsTranslations[r]
37 }))
38 }
39
30 get startAt () { 40 get startAt () {
31 return durationToString(this.abuse.video.startAt) 41 return durationToString(this.abuse.video.startAt)
32 } 42 }
@@ -34,13 +44,4 @@ export class AbuseDetailsComponent {
34 get endAt () { 44 get endAt () {
35 return durationToString(this.abuse.video.endAt) 45 return durationToString(this.abuse.video.endAt)
36 } 46 }
37
38 getPredefinedReasons () {
39 if (!this.abuse.predefinedReasons) return []
40
41 return this.abuse.predefinedReasons.map(r => ({
42 id: r,
43 label: this.predefinedReasonsTranslations[r]
44 }))
45 }
46} 47}