Skip to content
This repository was archived by the owner on Nov 8, 2022. It is now read-only.

Commit 96a23c3

Browse files
committed
fix(AvatarRows): uniq by id
1 parent 84dd77a commit 96a23c3

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

components/AvatarsRow/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ const validUser = R.compose(
2929
R.isNil
3030
)
3131

32+
const getUniqueArray = (arr, comp) => {
33+
const unique = arr
34+
.map(e => e[comp])
35+
36+
// store the keys of the unique objects
37+
.map((e, i, final) => final.indexOf(e) === i && i)
38+
39+
// eliminate the dead keys & store unique objects
40+
.filter(e => arr[e])
41+
.map(e => arr[e])
42+
43+
return unique
44+
}
45+
3246
const AvatarsRow = ({
3347
users,
3448
total,
@@ -42,7 +56,7 @@ const AvatarsRow = ({
4256
return <span />
4357
}
4458

45-
users = R.filter(validUser, R.uniqBy(R.path('id'), users))
59+
users = R.filter(validUser, getUniqueArray(users, 'id'))
4660
const sortedUsers = reverse ? users : R.reverse(users)
4761

4862
return (

0 commit comments

Comments
 (0)