diff --git a/apps/client/src/app/components/home-summary/home-summary.component.ts b/apps/client/src/app/components/home-summary/home-summary.component.ts index c494db604..d25a5be9a 100644 --- a/apps/client/src/app/components/home-summary/home-summary.component.ts +++ b/apps/client/src/app/components/home-summary/home-summary.component.ts @@ -6,7 +6,6 @@ import { hasPermission, permissions } from '@ghostfolio/common/permissions'; import { DataService } from '@ghostfolio/ui/services'; import { - ChangeDetectorRef, Component, computed, CUSTOM_ELEMENTS_SCHEMA, @@ -27,16 +26,22 @@ import { DeviceDetectorService } from 'ngx-device-detector'; templateUrl: './home-summary.html' }) export class GfHomeSummaryComponent implements OnInit { - protected readonly deviceType = computed( - () => this.deviceDetectorService.deviceInfo().deviceType - ); protected readonly hasImpersonationId = signal(false); - protected hasPermissionToUpdateUserSettings: boolean; protected readonly isLoading = signal(true); protected readonly summary = signal(undefined); - protected user: User; + protected readonly user = signal(undefined); + + protected readonly deviceType = computed( + () => this.deviceDetectorService.deviceInfo().deviceType + ); + + protected readonly hasPermissionToUpdateUserSettings = computed(() => { + const user = this.user(); + return user + ? hasPermission(user.permissions, permissions.updateUserSettings) + : false; + }); - private readonly changeDetectorRef = inject(ChangeDetectorRef); private readonly dataService = inject(DataService); private readonly destroyRef = inject(DestroyRef); private readonly deviceDetectorService = inject(DeviceDetectorService); @@ -50,13 +55,7 @@ export class GfHomeSummaryComponent implements OnInit { .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((state) => { if (state?.user) { - this.user = state.user; - - this.hasPermissionToUpdateUserSettings = hasPermission( - this.user.permissions, - permissions.updateUserSettings - ); - + this.user.set(state.user); this.update(); } }); @@ -80,9 +79,7 @@ export class GfHomeSummaryComponent implements OnInit { .get(true) .pipe(takeUntilDestroyed(this.destroyRef)) .subscribe((user) => { - this.user = user; - - this.changeDetectorRef.markForCheck(); + this.user.set(user); }); }); } diff --git a/apps/client/src/app/components/home-summary/home-summary.html b/apps/client/src/app/components/home-summary/home-summary.html index 28d9d8cd4..a6da72b03 100644 --- a/apps/client/src/app/components/home-summary/home-summary.html +++ b/apps/client/src/app/components/home-summary/home-summary.html @@ -5,17 +5,17 @@