Skip to content

Commit

Permalink
Bugfix for release v61.4
Browse files Browse the repository at this point in the history
(cherry picked from commit e83fa7a)
  • Loading branch information
oharsta authored and baszoetekouw committed Jan 23, 2025
1 parent 1c13678 commit b908da5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions client/src/__tests__/utils/Utils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ test("Remove duplicates", () => {
]);
});

test("Remove duplicates with undefined", () => {
const arr = [
{id: 1, name: "one"},
{id: 1, name: "one"},
undefined
];
const unique = removeDuplicates(arr, "id");
expect(unique).toEqual([
{id: 1, name: "one"},
]);
});

test("splitListSemantically", () => {
const arr = ["1", "2", "3", "4"]
expect(splitListSemantically(arr, "and")).toEqual("1, 2, 3 and 4");
Expand Down
5 changes: 4 additions & 1 deletion client/src/utils/Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ export function escapeDeep(obj) {
}

export const removeDuplicates = (arr, attr) => arr
.filter((obj, pos, arr) => arr.map(mapObj => mapObj[attr]).indexOf(obj[attr]) === pos);
.filter((obj, pos, arr) => arr
.filter(filObj => !isEmpty(filObj))
.map(mapObj => mapObj[attr])
.indexOf((obj || {})[attr]) === pos);

export const ErrorOrigins = {
invitationNotFound: "invitationNotFound",
Expand Down

0 comments on commit b908da5

Please sign in to comment.