Skip to content

Commit

Permalink
fix duplicate usernames selector
Browse files Browse the repository at this point in the history
  • Loading branch information
vinkabuki committed Sep 12, 2023
1 parent 9605d91 commit 43513ed
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions packages/state-manager/src/sagas/users/users.selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,18 @@ export const csrsMapping = createSelector(csrs, csrs => {

export const allUsers = createSelector(csrsMapping, certificatesMapping, (csrs, certs) => {
const users: Record<string, User> = {}
const usernames: string[] = []
const allUsernames: string[] = Object.values(csrs).map(u => u.username)
const duplicateUsernames: string[] = allUsernames.filter((val, index) => allUsernames.indexOf(val) !== index)
console.log('duplicate Usernames selector', duplicateUsernames)
Object.keys(csrs).map(pubKey => {
const username = csrs[pubKey].username
const isDuplicated = usernames.includes(username)
const isDuplicated = duplicateUsernames.includes(username)
const isRegistered = Boolean(certs[pubKey])
users[pubKey] = {
...csrs[pubKey],
isRegistered,
isDuplicated
}
usernames.push(username)
})
return users
})
Expand Down

0 comments on commit 43513ed

Please sign in to comment.