refactor: initialize config via APP_INITIALIZER

Closes #181
This commit is contained in:
Jovan Krunić
2022-02-09 20:43:08 +01:00
parent 411e0970b8
commit bde0df219c
9 changed files with 37 additions and 72 deletions

View File

@@ -23,7 +23,7 @@ import {ConfigProvider} from '../../config/config.provider';
styleUrls: ['about-page.scss'],
})
export class AboutPageComponent implements OnInit {
content: Promise<SCAboutPage>;
content: SCAboutPage;
constructor(
private readonly route: ActivatedRoute,
@@ -33,12 +33,11 @@ export class AboutPageComponent implements OnInit {
async ngOnInit() {
const route = this.route.snapshot.url.map(it => it.path).join('/');
this.content = new Promise(resolve => {
this.configProvider
.getValue('aboutPages')
.then(value =>
resolve((value as SCAppConfiguration['aboutPages'])[route] ?? {}),
);
});
this.content =
(
this.configProvider.getValue(
'aboutPages',
) as SCAppConfiguration['aboutPages']
)[route] ?? {};
}
}