From f3ae606caf74c8a173ce44bf3f913f1488f97d7f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 25 Apr 2019 10:40:01 +0200 Subject: Wait config before loading login/signup --- client/src/app/core/core.module.ts | 4 +++- .../app/core/routing/server-config-resolver.service.ts | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 client/src/app/core/routing/server-config-resolver.service.ts (limited to 'client/src/app/core') diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index 4ef3b1e73..d3e72afb4 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts @@ -19,6 +19,7 @@ import { ToastModule } from 'primeng/toast' import { Notifier } from './notification' import { MessageService } from 'primeng/api' import { UserNotificationSocket } from '@app/core/notification/user-notification-socket.service' +import { ServerConfigResolver } from './routing/server-config-resolver.service' @NgModule({ imports: [ @@ -60,7 +61,8 @@ import { UserNotificationSocket } from '@app/core/notification/user-notification RedirectService, Notifier, MessageService, - UserNotificationSocket + UserNotificationSocket, + ServerConfigResolver ] }) export class CoreModule { diff --git a/client/src/app/core/routing/server-config-resolver.service.ts b/client/src/app/core/routing/server-config-resolver.service.ts new file mode 100644 index 000000000..ec7d6428f --- /dev/null +++ b/client/src/app/core/routing/server-config-resolver.service.ts @@ -0,0 +1,17 @@ +import { Injectable } from '@angular/core' +import { Resolve } from '@angular/router' +import { ServerService } from '@app/core/server' + +@Injectable() +export class ServerConfigResolver implements Resolve { + constructor ( + private server: ServerService + ) {} + + resolve () { + // FIXME: directly returning this.server.configLoaded does not seem to work + return new Promise(res => { + return this.server.configLoaded.subscribe(() => res(true)) + }) + } +} -- cgit v1.2.3