Revize c335ea37
Přidáno uživatelem Hung Hoang před téměř 6 roky(ů)
webapp/src/app/services/util/profile.service.ts | ||
---|---|---|
1 | 1 |
import {Injectable} from '@angular/core'; |
2 | 2 |
import {UserService} from '../api/user.service'; |
3 | 3 |
import {UserProfile} from '../../models/user.model'; |
4 |
import {Observable} from 'rxjs'; |
|
4 |
import {Observable, of} from 'rxjs';
|
|
5 | 5 |
|
6 | 6 |
@Injectable({ |
7 | 7 |
providedIn: 'root' |
... | ... | |
22 | 22 |
* the changes to logged user would not be seen until |
23 | 23 |
* the user logged off and then logged back in |
24 | 24 |
*/ |
25 |
public getLoggedUser() { |
|
25 |
public getLoggedUser(cached?: boolean) { |
|
26 |
if (cached && this.isUserLogged()) { |
|
27 |
return of(this.profile); |
|
28 |
} |
|
29 |
|
|
26 | 30 |
return new Observable<UserProfile>((obs) => { |
27 | 31 |
this.userService.getLoggedUserProfile() |
28 | 32 |
.subscribe((userProfile: UserProfile) => { |
Také k dispozici: Unified diff
Clicking on menu item refreshes logged user profile data in profile service