Skip to content

Commit

Permalink
add an option to enable sorting
Browse files Browse the repository at this point in the history
  • Loading branch information
DeinFreund committed Sep 11, 2016
1 parent 125563c commit 3bc2a50
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
15 changes: 10 additions & 5 deletions comp/UserList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require('style/UserList.sass');
var _ = require('lodash');
var React = require('react');
var UserItem = require('comp/UserItem.jsx');
var Settings = require('store/Settings.js');

module.exports = React.createClass({
displayName: 'UserList',
Expand Down Expand Up @@ -37,11 +38,15 @@ module.exports = React.createClass({
}
userItems = userItems.sort(function(a, b){
return a.localeCompare(b);
}).sort(function(a, b){
return users[b].level - users[a].level;
}).sort(function(a, b){
return Math.floor(users[b].elo/200) - Math.floor(users[a].elo/200);
}).map(function(x){
});
if (Settings.sortColors) {
userItems = userItems.sort(function(a, b){
return users[b].level - users[a].level;
}).sort(function(a, b){
return Math.floor(users[b].elo/200) - Math.floor(users[a].elo/200);
});
}
userItems = userItems.map(function(x){
return <UserItem key={users[x].name} user={users[x]} battles={this.props.battles} />;
}.bind(this));
return <div className="userList">
Expand Down
1 change: 1 addition & 0 deletions store/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ module.exports = Reflux.createStore({
},
"Chat": {
autoJoin: { val: '#weblobby', name: 'Autojoin channels/private messages', type: 'list', desc: 'Can be changed by pressing the heart button in chat. Channels are prefixed with #.' },
sortColors: { val: true, name: 'Sort players by rank', type: 'bool' },
},
"Games to show in battle list": {
selectedEvo: { val: true, name: 'Evolution RTS', type: 'bool' },
Expand Down

0 comments on commit 3bc2a50

Please sign in to comment.