diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7c728cf6504..d7b46ab712f 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -30,9 +30,13 @@ export function initialize( userService: UserService ): () => Promise { return (): Promise => { - return userService.retrieveUserPromise().then((user) => { - userService.getUser().subscribe((user) => { - configService.retrieveConfig(); + return new Promise((resolve) => { + userService.retrieveUserPromise().then(() => { + return userService.getUser().subscribe(() => { + return configService.retrieveConfig().subscribe((config) => { + resolve(config); + }); + }); }); }); }; diff --git a/src/app/services/config.service.ts b/src/app/services/config.service.ts index 7ce8b27211a..2bcda211b5e 100644 --- a/src/app/services/config.service.ts +++ b/src/app/services/config.service.ts @@ -1,6 +1,6 @@ import { Injectable } from '@angular/core'; import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { BehaviorSubject, Observable } from 'rxjs'; +import { BehaviorSubject, Observable, tap } from 'rxjs'; import { Config } from '../domain/config'; import { Announcement } from '../domain/announcement'; @@ -17,14 +17,16 @@ export class ConfigService { return this.config$; } - retrieveConfig() { + retrieveConfig(): Observable { const headers = new HttpHeaders({ 'Cache-Control': 'no-cache' }); - this.http + return this.http .get(this.userConfigUrl, { headers: headers }) - .subscribe((config) => { - this.config$.next(config); - this.timeDiff = Date.now() - config.currentTime; - }); + .pipe( + tap((config) => { + this.config$.next(config); + this.timeDiff = Date.now() - config.currentTime; + }) + ); } getContextPath() {