Skip to content

Commit e4de984

Browse files
authored
merge: fix: enforce uniqueness in selectedTechs and selectedSocials to preve… (#7819)
## Description Fixes #7804 Previously, rapidly double-clicking a skill badge in the generator UI before the React state had a chance to update could result in duplicate entries being pushed to the selection array, causing identical badges to render side-by-side in the final markdown output. This PR updates `GeneratorClient.tsx` to wrap incoming arrays for both `selectedTechs` and `selectedSocials` in a `Set`. This enforces strict uniqueness at the top level of the state, guaranteeing that duplicate badges can never be added to the array regardless of how quickly a user interacts with the UI. ## Pillar - [ ] 🎨 Pillar 1 — New Theme Design - [ ] 📐 Pillar 2 — Geometric SVG Improvement - [ ] 🕐 Pillar 3 — Timezone Logic Optimization - [x] 🛠️ Other (Bug fix, refactoring, docs) ## Checklist before requesting a review: - [x] I have read the `CONTRIBUTING.md` file. - [x] I have tested these changes locally (`localhost:3000/api/streak?user=YOUR_USERNAME`). - [x] I have run `npm run format` and `npm run lint` locally and resolved all errors (CI will fail otherwise). - [x] My commits follow the Conventional Commits format (e.g., `feat(themes): ...`, `fix(calculate): ...`). - [ ] I have updated `README.md` if I added a new theme or URL parameter. - [x] I have started the repo. - [x] I have made sure that i have only one commit to merge in this PR. - [x] The SVG output matches the CommitPulse "premium quality" aesthetic standard (no raw elements, smooth animations, correct fonts). - [x] (Recommended) I joined the CommitPulse Discord community for contributor discussions, mentorship, and faster PR support.
2 parents 2bbcd2c + ed183cc commit e4de984

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

app/generator/GeneratorClient.tsx

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,11 @@ export function GeneratorClient() {
7171
confirmOverwrite || !prevState.description
7272
? data.description || prevState.description
7373
: prevState.description,
74-
selectedTechs: Array.from(new Set([...prevState.selectedTechs, ...data.selectedTechs])),
74+
selectedTechs: Array.from(
75+
new Set([...prevState.selectedTechs, ...(data.selectedTechs || [])])
76+
),
7577
selectedSocials: Array.from(
76-
new Set([...prevState.selectedSocials, ...data.selectedSocials])
78+
new Set([...prevState.selectedSocials, ...(data.selectedSocials || [])])
7779
),
7880
socialLinks: { ...prevState.socialLinks, ...data.socialLinks },
7981
};
@@ -87,8 +89,12 @@ export function GeneratorClient() {
8789
state={state}
8890
onNameChange={(v) => setState((s) => ({ ...s, name: v }))}
8991
onDescriptionChange={(v) => setState((s) => ({ ...s, description: v }))}
90-
onTechsChange={(ids) => setState((s) => ({ ...s, selectedTechs: ids }))}
91-
onSocialsChange={(ids) => setState((s) => ({ ...s, selectedSocials: ids }))}
92+
onTechsChange={(ids) =>
93+
setState((s) => ({ ...s, selectedTechs: Array.from(new Set(ids)) }))
94+
}
95+
onSocialsChange={(ids) =>
96+
setState((s) => ({ ...s, selectedSocials: Array.from(new Set(ids)) }))
97+
}
9298
onSocialLinkChange={(id, url) =>
9399
setState((s) => ({
94100
...s,

0 commit comments

Comments
 (0)