@@ -19,12 +19,12 @@ import { AlertService } from '~core/services/alert.service';
1919import { takeUntilDestroyed } from '@angular/core/rxjs-interop' ;
2020
2121@Component ( {
22- selector : 'app-my-pokemon' ,
23- templateUrl : './my-pokemon.component.html' ,
24- styleUrl : './my-pokemon.component.scss' ,
25- imports : [ PokemonCardComponent , NgOptimizedImage , PokemonSearchComponent ] ,
26- changeDetection : ChangeDetectionStrategy . OnPush ,
27- schemas : [ CUSTOM_ELEMENTS_SCHEMA ]
22+ selector : 'app-my-pokemon' ,
23+ templateUrl : './my-pokemon.component.html' ,
24+ styleUrl : './my-pokemon.component.scss' ,
25+ imports : [ PokemonCardComponent , NgOptimizedImage , PokemonSearchComponent ] ,
26+ changeDetection : ChangeDetectionStrategy . OnPush ,
27+ schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
2828} )
2929export class MyPokemonComponent implements OnInit {
3030 private readonly userService = inject ( UserService ) ;
@@ -44,8 +44,7 @@ export class MyPokemonComponent implements OnInit {
4444 . subscribe ( {
4545 next : ( user ) => {
4646 this . user = user ;
47-
48- if ( this . user . caughtPokemonIds ) {
47+ if ( this . user . caughtPokemonIds . length > 0 ) {
4948 this . pokemonService
5049 . getPokemons ( this . user . caughtPokemonIds )
5150 . pipe ( takeUntilDestroyed ( this . destroyRef ) )
@@ -58,6 +57,9 @@ export class MyPokemonComponent implements OnInit {
5857 this . alertService . createErrorAlert ( translations . genericErrorAlert ) ;
5958 } ,
6059 } ) ;
60+ } else {
61+ this . userPokemon = [ ] ;
62+ this . changeDetectorRef . markForCheck ( ) ;
6163 }
6264 } ,
6365 } ) ;
0 commit comments