Skip to content

Commit

Permalink
Fixing duplicate roles in filter bug
Browse files Browse the repository at this point in the history
  • Loading branch information
DXCanas committed Aug 8, 2016
1 parent eb6546e commit 68e7df3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 0 additions & 2 deletions kolibri/plugins/management/assets/src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ function showUserPage(store) {
const users = responses[1];
const roles = responses[2];

console.log(id, users, roles)
;
store.dispatch('SET_FACILITY', id[0]); // for mvp, we assume only one facility exists
store.dispatch('SET_ROLES', roles);
store.dispatch('ADD_USERS', users);
Expand Down
11 changes: 10 additions & 1 deletion kolibri/plugins/management/assets/src/state/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,16 @@ const mutations = {
},

SET_ROLES(state, roles) {
state.roles = roles;
// used to efficiently check for dupes
const uniqueRoles = {};
// returns array with removed duplicates
state.roles = roles.filter(role => {
if (uniqueRoles.hasOwnProperty(role)) {
return false;
}

return (uniqueRoles[role] = true);
});
},
};

Expand Down

0 comments on commit 68e7df3

Please sign in to comment.