Check environment for userInfoSubject

This commit is contained in:
Konstantinos Triantafyllou 2021-11-08 11:36:28 +02:00
parent 1488f8ef00
commit 23dc2cc074
1 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,6 @@
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {from, Observable} from "rxjs";
import {BehaviorSubject, from, Observable} from "rxjs";
import {COOKIE, Session, User} from "../login/utils/helper.class";
import {map} from "rxjs/operators";
import {NavigationEnd, Router} from "@angular/router";
@ -14,7 +14,7 @@ import {AdvancedAsyncSubject} from "../utils/AdvancedAsyncSubject";
})
export class UserManagementService {
private getUserInfoSubject: AdvancedAsyncSubject<User> = new AdvancedAsyncSubject<User>();
private getUserInfoSubject: AdvancedAsyncSubject<User> | BehaviorSubject<User>;
public fixRedirectURL: string = null;
private redirectUrl: string = null;
private readonly promise: Promise<User>;
@ -23,6 +23,11 @@ export class UserManagementService {
constructor(private http: HttpClient,
private router: Router) {
if(properties.environment === "development") {
this.getUserInfoSubject = new AdvancedAsyncSubject<User>();
} else {
this.getUserInfoSubject = new BehaviorSubject<User>(null)
}
this.promise = new Promise<any>((resolve => {
this.updateUserInfo(resolve);
}));