72699: Hard redirect after log in - loading fixes

This commit is contained in:
Kristof De Langhe
2020-08-27 14:50:13 +02:00
parent 7fbae8997d
commit 55c45f5f6c
25 changed files with 204 additions and 146 deletions

View File

@@ -1,4 +1,4 @@
import { delay, filter, map, take } from 'rxjs/operators';
import { delay, filter, map, take, distinctUntilChanged } from 'rxjs/operators';
import {
AfterViewInit,
ChangeDetectionStrategy,
@@ -19,7 +19,7 @@ import { MetadataService } from './core/metadata/metadata.service';
import { HostWindowResizeAction } from './shared/host-window.actions';
import { HostWindowState } from './shared/search/host-window.reducer';
import { NativeWindowRef, NativeWindowService } from './core/services/window.service';
import { isAuthenticated } from './core/auth/selectors';
import { isAuthenticated, isAuthenticationLoading } from './core/auth/selectors';
import { AuthService } from './core/auth/auth.service';
import { CSSVariableService } from './shared/sass-helper/sass-helper.service';
import { MenuService } from './shared/menu/menu.service';
@@ -52,6 +52,11 @@ export class AppComponent implements OnInit, AfterViewInit {
notificationOptions = environment.notifications;
models;
/**
* Whether or not the authenticated has finished loading
*/
hasAuthFinishedLoading$: Observable<boolean>;
constructor(
@Inject(NativeWindowService) private _window: NativeWindowRef,
private translate: TranslateService,
@@ -89,6 +94,10 @@ export class AppComponent implements OnInit, AfterViewInit {
}
ngOnInit() {
this.hasAuthFinishedLoading$ = this.store.pipe(select(isAuthenticationLoading)).pipe(
map((isLoading: boolean) => isLoading === false),
distinctUntilChanged()
);
const env: string = environment.production ? 'Production' : 'Development';
const color: string = environment.production ? 'red' : 'green';
console.info(`Environment: %c${env}`, `color: ${color}; font-weight: bold;`);