From 00fcf80462aaac2cc2a55ae93e3e67b6f1e4a8ae Mon Sep 17 00:00:00 2001 From: Dan Date: Wed, 20 Nov 2024 16:02:38 +0000 Subject: [PATCH] - Protected a few calls till we are authenticated --- src/app/app.component.ts | 8 +++++++- .../plan/plan-pokemon/plan-pokemonV2.component.ts | 3 +-- src/app/features/plan/planV2.component.ts | 14 ++++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 6c4da67..0b5e43b 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -144,9 +144,15 @@ export class AppComponent { constructor( public auth: AuthService, public pokemonService: PokemonService, + private authService: AuthService, private router: Router ) { - this.pokemonService.initializeCaughtPokemon(); + this.authService.isAuthenticated$.subscribe((isAuthenticated) => { + if (isAuthenticated) { + this.pokemonService.initializeCaughtPokemon(); + console.log("Loading Plan") + } + }); } isRouteSelected(route: string): boolean { diff --git a/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts b/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts index 242f59c..43424d5 100644 --- a/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts +++ b/src/app/features/plan/plan-pokemon/plan-pokemonV2.component.ts @@ -178,8 +178,8 @@ export class PlanPokemonV2Component { ngOnInit() { this.representative_pokemon = null; - this.handlePokemonFamilyChange(this.pokemon_family); this.catch_count = this.pokemon_family.catch_count; + this.handlePokemonFamilyChange(this.pokemon_family); } ngOnChanges(changes: SimpleChanges) { @@ -213,7 +213,6 @@ export class PlanPokemonV2Component { }); this.updateCatchCount(); - this.cdr.markForCheck(); } get hasTargets(): boolean { diff --git a/src/app/features/plan/planV2.component.ts b/src/app/features/plan/planV2.component.ts index 94df193..4134245 100644 --- a/src/app/features/plan/planV2.component.ts +++ b/src/app/features/plan/planV2.component.ts @@ -8,6 +8,7 @@ import { GamePlan, PokemonFamilyEntry } from '../../core/models/plan.model'; import { PlanPokemonV2Component } from "./plan-pokemon/plan-pokemonV2.component"; import { ScrollingModule, CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; import { PlanPokemonDetailsComponent } from "./plan-pokemon-details/plan-pokemon-details.component"; +import { AuthService } from '../../core/services/auth.service'; @Component({ selector: 'app-planV2', @@ -147,10 +148,19 @@ export class PlanV2Component implements OnInit { selectedGame: GamePlan | null = null; selectedPokemon: PokemonFamilyEntry | null = null; - constructor(private planService: PlanService, private cdr: ChangeDetectorRef) {} + constructor( + private planService: PlanService, + private cdr: ChangeDetectorRef, + private authService: AuthService + ) {} ngOnInit() { - this.loadPlan(); + this.authService.isAuthenticated$.subscribe((isAuthenticated) => { + if (isAuthenticated) { + this.loadPlan(); + console.log("Loading Plan") + } + }); } private loadPlan() {