diff options
author | Chocobozzz <me@florianbigard.com> | 2020-02-03 10:31:34 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-02-03 10:33:08 +0100 |
commit | b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d (patch) | |
tree | dd00268a13ef51c77ceaaeb2ffbcd874e6f177df /client/src/app/+about/about-instance/about-instance.component.ts | |
parent | a15871560f80e07386c1dabb8370cd2664ecfd1f (diff) | |
download | PeerTube-b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d.tar.gz PeerTube-b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d.tar.zst PeerTube-b42f9c400e7b677046ab0034a3cf7aaaa73ecb6d.zip |
Use a resolver for the about page
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 | 49 |
1 files changed, 17 insertions, 32 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 87beb13da..c8c156105 100644 --- a/client/src/app/+about/about-instance/about-instance.component.ts +++ b/client/src/app/+about/about-instance/about-instance.component.ts | |||
@@ -1,12 +1,10 @@ | |||
1 | import { Component, OnInit, ViewChild } from '@angular/core' | 1 | import { Component, OnInit, ViewChild } from '@angular/core' |
2 | import { Notifier, ServerService } from '@app/core' | 2 | import { Notifier, ServerService } from '@app/core' |
3 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
4 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' | 3 | import { ContactAdminModalComponent } from '@app/+about/about-instance/contact-admin-modal.component' |
5 | import { InstanceService } from '@app/shared/instance/instance.service' | 4 | import { InstanceService } from '@app/shared/instance/instance.service' |
6 | import { MarkdownService } from '@app/shared/renderer' | ||
7 | import { forkJoin } from 'rxjs' | ||
8 | import { map, switchMap } from 'rxjs/operators' | ||
9 | import { ServerConfig } from '@shared/models' | 5 | import { ServerConfig } from '@shared/models' |
6 | import { ActivatedRoute } from '@angular/router' | ||
7 | import { ResolverData } from './about-instance.resolver' | ||
10 | 8 | ||
11 | @Component({ | 9 | @Component({ |
12 | selector: 'my-about-instance', | 10 | selector: 'my-about-instance', |
@@ -37,11 +35,10 @@ export class AboutInstanceComponent implements OnInit { | |||
37 | serverConfig: ServerConfig | 35 | serverConfig: ServerConfig |
38 | 36 | ||
39 | constructor ( | 37 | constructor ( |
38 | private route: ActivatedRoute, | ||
40 | private notifier: Notifier, | 39 | private notifier: Notifier, |
41 | private serverService: ServerService, | 40 | private serverService: ServerService, |
42 | private instanceService: InstanceService, | 41 | private instanceService: InstanceService |
43 | private markdownService: MarkdownService, | ||
44 | private i18n: I18n | ||
45 | ) {} | 42 | ) {} |
46 | 43 | ||
47 | get instanceName () { | 44 | get instanceName () { |
@@ -56,35 +53,23 @@ export class AboutInstanceComponent implements OnInit { | |||
56 | return this.serverConfig.instance.isNSFW | 53 | return this.serverConfig.instance.isNSFW |
57 | } | 54 | } |
58 | 55 | ||
59 | ngOnInit () { | 56 | async ngOnInit () { |
60 | this.serverConfig = this.serverService.getTmpConfig() | 57 | this.serverConfig = this.serverService.getTmpConfig() |
61 | this.serverService.getConfig() | 58 | this.serverService.getConfig() |
62 | .subscribe(config => this.serverConfig = config) | 59 | .subscribe(config => this.serverConfig = config) |
63 | 60 | ||
64 | this.instanceService.getAbout() | 61 | const { about, languages, categories }: ResolverData = this.route.snapshot.data.instanceData |
65 | .pipe( | 62 | |
66 | switchMap(about => { | 63 | this.languages = languages |
67 | return forkJoin([ | 64 | this.categories = categories |
68 | this.instanceService.buildTranslatedLanguages(about), | 65 | |
69 | this.instanceService.buildTranslatedCategories(about) | 66 | this.shortDescription = about.instance.shortDescription |
70 | ]).pipe(map(([ languages, categories ]) => ({ about, languages, categories }))) | 67 | |
71 | }) | 68 | this.creationReason = about.instance.creationReason |
72 | ).subscribe( | 69 | this.maintenanceLifetime = about.instance.maintenanceLifetime |
73 | async ({ about, languages, categories }) => { | 70 | this.businessModel = about.instance.businessModel |
74 | this.languages = languages | 71 | |
75 | this.categories = categories | 72 | this.html = await this.instanceService.buildHtml(about) |
76 | |||
77 | this.shortDescription = about.instance.shortDescription | ||
78 | |||
79 | this.creationReason = about.instance.creationReason | ||
80 | this.maintenanceLifetime = about.instance.maintenanceLifetime | ||
81 | this.businessModel = about.instance.businessModel | ||
82 | |||
83 | this.html = await this.instanceService.buildHtml(about) | ||
84 | }, | ||
85 | |||
86 | () => this.notifier.error(this.i18n('Cannot get about information from server')) | ||
87 | ) | ||
88 | } | 73 | } |
89 | 74 | ||
90 | openContactModal () { | 75 | openContactModal () { |