simpler filter code

This commit is contained in:
Faye Li 2017-02-15 10:23:36 -08:00
parent 5ece3f1e1a
commit 8aae2aa5f0

View file

@ -364,12 +364,13 @@
}
}
function isOtherUsers(user) {
return user.username != myUsername;
}
function processData(data, type) {
// Filter out yourself from the users list
var removeIndex = data.users.map(function(user) { return user.username }).indexOf(myUsername);
if (removeIndex >= 0) {
data.users.splice(removeIndex,1);
}
data.users = data.users.filter(isOtherUsers);
// Sort array alphabetically by username
data.users.sort(function(a, b) {