import { UserService } from '@ghostfolio/client/services/user/user.service'; import { TabConfiguration, User } from '@ghostfolio/common/interfaces'; import { paths } from '@ghostfolio/common/paths'; import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core'; import { DeviceDetectorService } from 'ngx-device-detector'; import { Subject } from 'rxjs'; import { takeUntil } from 'rxjs/operators'; @Component({ host: { class: 'page has-tabs' }, selector: 'gf-zen-page', styleUrls: ['./zen-page.scss'], templateUrl: './zen-page.html', standalone: false }) export class ZenPageComponent implements OnDestroy, OnInit { public deviceType: string; public tabs: TabConfiguration[] = []; public user: User; private unsubscribeSubject = new Subject(); public constructor( private changeDetectorRef: ChangeDetectorRef, private deviceService: DeviceDetectorService, private userService: UserService ) { this.userService.stateChanged .pipe(takeUntil(this.unsubscribeSubject)) .subscribe((state) => { if (state?.user) { this.tabs = [ { iconName: 'analytics-outline', label: $localize`Overview`, path: ['/' + paths.zen] }, { iconName: 'wallet-outline', label: $localize`Holdings`, path: ['/' + paths.zen, paths.holdings] } ]; this.user = state.user; this.changeDetectorRef.markForCheck(); } }); } public ngOnInit() { this.deviceType = this.deviceService.getDeviceInfo().deviceType; } public ngOnDestroy() { this.unsubscribeSubject.next(); this.unsubscribeSubject.complete(); } }