diff options
Diffstat (limited to 'client/src/app/+about/about-instance/about-instance.component.ts')
-rw-r--r-- | client/src/app/+about/about-instance/about-instance.component.ts | 60 |
1 files changed, 40 insertions, 20 deletions
diff --git a/client/src/app/+about/about-instance/about-instance.component.ts b/client/src/app/+about/about-instance/about-instance.component.ts index b85a6be94..0af1dca9c 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts | |||
@@ -4,6 +4,9 @@ import { I18n } from '@ngx-translate/i18n-polyfill' | |||
4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' | 4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' |
5 | import { InstanceService } from '@app/shared/instance/instance.service' | 5 | import { InstanceService } from '@app/shared/instance/instance.service' |
6 | import { MarkdownService } from '@app/shared/renderer' | 6 | import { MarkdownService } from '@app/shared/renderer' |
7 | import { forkJoin } from 'rxjs' | ||
8 | import { first } from 'rxjs/operators' | ||
9 | import { peertubeTranslate } from '@shared/models' | ||
7 | 10 | ||
8 | @Component({ | 11 | @Component({ |
9 | selector: 'my-about-instance', | 12 | selector: 'my-about-instance', |
@@ -27,7 +30,7 @@ export class AboutInstanceComponent implements OnInit { | |||
27 | businessModel = '' | 30 | businessModel = '' |
28 | 31 | ||
29 | languages: string[] = [] | 32 | languages: string[] = [] |
30 | categories: number[] = [] | 33 | categories: string[] = [] |
31 | 34 | ||
32 | constructor ( | 35 | constructor ( |
33 | private notifier: Notifier, | 36 | private notifier: Notifier, |
@@ -50,28 +53,45 @@ export class AboutInstanceComponent implements OnInit { | |||
50 | } | 53 | } |
51 | 54 | ||
52 | ngOnInit () { | 55 | ngOnInit () { |
53 | this.instanceService.getAbout() | 56 | forkJoin([ |
54 | .subscribe( | 57 | this.instanceService.getAbout(), |
55 | async res => { | 58 | this.serverService.localeObservable.pipe(first()), |
56 | this.shortDescription = res.instance.shortDescription | 59 | this.serverService.videoLanguagesLoaded.pipe(first()), |
57 | 60 | this.serverService.videoCategoriesLoaded.pipe(first()) | |
58 | this.maintenanceLifetime = res.instance.maintenanceLifetime | 61 | ]).subscribe( |
59 | this.businessModel = res.instance.businessModel | 62 | async ([ res, translations ]) => { |
60 | 63 | this.shortDescription = res.instance.shortDescription | |
61 | for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) { | 64 | |
62 | this.html[key] = await this.markdownService.textMarkdownToHTML(res.instance[key]) | 65 | this.maintenanceLifetime = res.instance.maintenanceLifetime |
63 | } | 66 | this.businessModel = res.instance.businessModel |
64 | 67 | ||
65 | this.languages = res.instance.languages | 68 | for (const key of [ 'description', 'terms', 'codeOfConduct', 'moderationInformation', 'administrator' ]) { |
66 | this.categories = res.instance.categories | 69 | this.html[ key ] = await this.markdownService.textMarkdownToHTML(res.instance[ key ]) |
67 | }, | 70 | } |
68 | 71 | ||
69 | () => this.notifier.error(this.i18n('Cannot get about information from server')) | 72 | const languagesArray = this.serverService.getVideoLanguages() |
70 | ) | 73 | const categoriesArray = this.serverService.getVideoCategories() |
74 | |||
75 | this.languages = res.instance.languages | ||
76 | .map(l => { | ||
77 | const languageObj = languagesArray.find(la => la.id === l) | ||
78 | |||
79 | return peertubeTranslate(languageObj.label, translations) | ||
80 | }) | ||
81 | |||
82 | this.categories = res.instance.categories | ||
83 | .map(c => { | ||
84 | const categoryObj = categoriesArray.find(ca => ca.id === c) | ||
85 | |||
86 | return peertubeTranslate(categoryObj.label, translations) | ||
87 | }) | ||
88 | }, | ||
89 | |||
90 | () => this.notifier.error(this.i18n('Cannot get about information from server')) | ||
91 | ) | ||
71 | } | 92 | } |
72 | 93 | ||
73 | openContactModal () { | 94 | openContactModal () { |
74 | return this.contactAdminModal.show() | 95 | return this.contactAdminModal.show() |
75 | } | 96 | } |
76 | |||
77 | } | 97 | } |