diff --git a/src/app/core/services/pokemon.service.ts b/src/app/core/services/pokemon.service.ts index 4f7085a..19489ed 100644 --- a/src/app/core/services/pokemon.service.ts +++ b/src/app/core/services/pokemon.service.ts @@ -110,7 +110,7 @@ export class PokemonService { Image: "", IsDefault: row.data.is_default || false, IsGenderRelevant: row.data.gender_relevant, - IsCaught: this.caughtPokemon.has(row.PFIC) + IsCaught: this.caughtPokemon.has(row.pfic) } as Pokemon; pkmn.MarkIcon = this.getMarkImgName(pkmn.MarkName) pkmn.Image = this.getPokemonImageUrl(pkmn) @@ -147,13 +147,12 @@ export class PokemonService { } private updatePokemonCaughtStatus(pfic: string, isCaught: boolean) { - this.pokemonGroups.forEach(group => { - group.forEach(pokemon => { - if (pokemon && pokemon.PFIC === pfic) { - pokemon.IsCaught = isCaught; - } - }); - }); + if(this.pokemonFormMap.has(pfic)) { + const pkmn = this.pokemonFormMap.get(pfic) + if (pkmn) { + pkmn.IsCaught = isCaught; + } + } } getCaughtPokemon(): Observable { @@ -217,10 +216,7 @@ export class PokemonService { this.getCaughtPokemon().subscribe( pfics => { pfics.forEach(pfic => this.updateCaughtStatus(pfic, true)); - // If pokemon are already loaded, update their status - if (this.pokemonGroups.length > 0) { - pfics.forEach(pfic => this.updatePokemonCaughtStatus(pfic, true)); - } + pfics.forEach(pfic => this.updatePokemonCaughtStatus(pfic, true)); } ); }