diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 58b587072..be0a70745 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -303,7 +303,7 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { this.subs.add( this.store$ .select(userStore.getUserAuth) - .pipe(filter((userAuth) => !!userAuth.token)) + .pipe(filter((userAuth) => !!userAuth?.token)) .subscribe((_) => this.store$.dispatch(new userStore.LoadProfile())), ); @@ -361,10 +361,13 @@ export class AppComponent implements OnInit, OnDestroy, AfterViewInit { ), ); - const user = this.authService.getUser(); - if (user.id) { - this.store$.dispatch(new userStore.Login(user)); - } + this.subs.add( + this.authService.getUser().subscribe((user) => { + if (user?.id) { + this.store$.dispatch(new userStore.Login(user)); + } + }), + ); this.subs.add( this.actions$ diff --git a/src/app/components/header/header-buttons/header-buttons.component.ts b/src/app/components/header/header-buttons/header-buttons.component.ts index 021276ad5..e09de5402 100644 --- a/src/app/components/header/header-buttons/header-buttons.component.ts +++ b/src/app/components/header/header-buttons/header-buttons.component.ts @@ -26,6 +26,7 @@ import { AsfApiService, EnvironmentService, ScreenSizeService, + UserDataService, } from '@services'; import { CMRProduct, @@ -79,6 +80,7 @@ declare global { }) export class HeaderButtonsComponent implements OnInit, OnDestroy { authService = inject(AuthService); + userData = inject(UserDataService); env = inject(EnvironmentService); private http = inject(HttpClient); asfApiService = inject(AsfApiService); @@ -138,9 +140,9 @@ export class HeaderButtonsComponent implements OnInit, OnDestroy { ngOnInit() { this.subs.add( - this.store$ - .select(userStore.getUserAuth) - .subscribe((user) => (this.userAuth = user)), + this.store$.select(userStore.getUserAuth).subscribe((user) => { + this.userAuth = user; + }), ); this.subs.add( diff --git a/src/app/components/header/header-buttons/preferences/preferences.component.html b/src/app/components/header/header-buttons/preferences/preferences.component.html index e3193a416..c2967b398 100644 --- a/src/app/components/header/header-buttons/preferences/preferences.component.html +++ b/src/app/components/header/header-buttons/preferences/preferences.component.html @@ -1,6 +1,6 @@