Browse Source

feat(client): tighten up encapsulation and immutability

pull/6724/head
KenTandrian 1 month ago
parent
commit
67db3dc492
  1. 38
      apps/client/src/app/components/home-watchlist/home-watchlist.component.ts
  2. 2
      apps/client/src/app/components/home-watchlist/home-watchlist.html

38
apps/client/src/app/components/home-watchlist/home-watchlist.component.ts

@ -48,27 +48,29 @@ import { CreateWatchlistItemDialogParams } from './create-watchlist-item-dialog/
templateUrl: './home-watchlist.html' templateUrl: './home-watchlist.html'
}) })
export class GfHomeWatchlistComponent implements OnInit { export class GfHomeWatchlistComponent implements OnInit {
public hasImpersonationId: boolean; protected hasImpersonationId: boolean;
public hasPermissionToCreateWatchlistItem: boolean; protected hasPermissionToCreateWatchlistItem: boolean;
public hasPermissionToDeleteWatchlistItem: boolean; protected hasPermissionToDeleteWatchlistItem: boolean;
public user: User; protected user: User;
public watchlist: Benchmark[]; protected watchlist: Benchmark[];
private readonly deviceDetectorService = inject(DeviceDetectorService); protected readonly deviceType = computed(
private readonly deviceType = computed(
() => this.deviceDetectorService.deviceInfo().deviceType () => this.deviceDetectorService.deviceInfo().deviceType
); );
public constructor( private readonly changeDetectorRef = inject(ChangeDetectorRef);
private changeDetectorRef: ChangeDetectorRef, private readonly dataService = inject(DataService);
private dataService: DataService, private readonly destroyRef = inject(DestroyRef);
private destroyRef: DestroyRef, private readonly deviceDetectorService = inject(DeviceDetectorService);
private dialog: MatDialog, private readonly dialog = inject(MatDialog);
private impersonationStorageService: ImpersonationStorageService, private readonly impersonationStorageService = inject(
private route: ActivatedRoute, ImpersonationStorageService
private router: Router, );
private userService: UserService private readonly route = inject(ActivatedRoute);
) { private readonly router = inject(Router);
private readonly userService = inject(UserService);
public constructor() {
this.impersonationStorageService this.impersonationStorageService
.onChangeHasImpersonation() .onChangeHasImpersonation()
.pipe(takeUntilDestroyed(this.destroyRef)) .pipe(takeUntilDestroyed(this.destroyRef))
@ -114,7 +116,7 @@ export class GfHomeWatchlistComponent implements OnInit {
this.loadWatchlistData(); this.loadWatchlistData();
} }
public onWatchlistItemDeleted({ protected onWatchlistItemDeleted({
dataSource, dataSource,
symbol symbol
}: AssetProfileIdentifier) { }: AssetProfileIdentifier) {

2
apps/client/src/app/components/home-watchlist/home-watchlist.html

@ -11,7 +11,7 @@
<div class="col-xs-12 col-md-10 offset-md-1"> <div class="col-xs-12 col-md-10 offset-md-1">
<gf-benchmark <gf-benchmark
[benchmarks]="watchlist" [benchmarks]="watchlist"
[deviceType]="deviceType" [deviceType]="deviceType()"
[hasPermissionToDeleteItem]="hasPermissionToDeleteWatchlistItem" [hasPermissionToDeleteItem]="hasPermissionToDeleteWatchlistItem"
[locale]="user?.settings?.locale || undefined" [locale]="user?.settings?.locale || undefined"
[user]="user" [user]="user"

Loading…
Cancel
Save