Skip to content

Commit

Permalink
Fixed edit profile duplicated items id by sanitizing them upon saving
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-oki authored Sep 18, 2024
1 parent f3d25e8 commit 779fd80
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions frontend/src/pages/Settings/Languages/table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ const Table: FunctionComponent = () => {
}) => {
return (
<Group gap="xs" wrap="nowrap">
{items.map((v) => {
{items.map((v, i) => {
const isCutoff = v.id === cutoff || cutoff === anyCutoff;
return (
<ItemBadge key={v.id} cutoff={isCutoff} item={v}></ItemBadge>
<ItemBadge key={i} cutoff={isCutoff} item={v}></ItemBadge>
);
})}
</Group>
Expand Down Expand Up @@ -148,9 +148,19 @@ const Table: FunctionComponent = () => {
icon={faWrench}
c="gray"
onClick={() => {
// We once had an issue on the past where there were duplicated
// item ids that needs to become unique upon editing.
const sanitizedProfile = {
...cloneDeep(profile),
items: profile.items.map((value, index) => {
return { ...value, id: index + 1 };
}),
tag: profile.tag || undefined,
};

modals.openContextModal(ProfileEditModal, {
languages,
profile: cloneDeep(profile),
profile: sanitizedProfile,
onComplete: updateProfile,
});
}}
Expand Down

0 comments on commit 779fd80

Please sign in to comment.