Skip to content

Commit

Permalink
fix(generator): prevent generated palette from having duplicate color…
Browse files Browse the repository at this point in the history
… names
  • Loading branch information
pawcoding committed Aug 16, 2024
1 parent c254365 commit 4272690
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/app/shared/data-access/palette.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Value } from '../model';
import { Color } from '../model/color.model';
import { Palette } from '../model/palette.model';
import { Shade } from '../model/shade.model';
import { deduplicateName } from '../utils/deduplicate-name';
import { ColorNameService } from './color-name.service';
import { ColorService } from './color.service';
import { ListService } from './list.service';
Expand Down Expand Up @@ -120,7 +121,11 @@ export class PaletteService {

for (const color of palette.colors) {
// Get the color name
color.name = await this._colorNameService.getColorName(color.shades[0]);
const generatedName = await this._colorNameService.getColorName(color.shades[0]);

// Deduplicate the name
const existingNames = palette.colors.map((c) => c.name);
color.name = deduplicateName(generatedName, existingNames);

// Regenerate the shades
await this._colorService.regenerateShades(color);
Expand Down

0 comments on commit 4272690

Please sign in to comment.