Skip to content

Commit

Permalink
Sort collateral ratio by ratio instead of price #430
Browse files Browse the repository at this point in the history
  • Loading branch information
svk31 committed Oct 23, 2017
1 parent b3b3193 commit 49d1138
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/components/Blockchain/Asset.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ class Asset extends React.Component {

const {sortDirection} = this.state;

let filterFunctions = {
let sortFunctions = {
name: function(a, b) {
let nameA = ChainStore.getAccount(a.borrower, false);
if (nameA) nameA = nameA.get("name");
Expand All @@ -547,6 +547,9 @@ class Asset extends React.Component {
},
debt: function(a, b) {
return (sortDirection ? 1 : -1) * (b.amountToReceive().getAmount() - a.amountToReceive().getAmount());
},
ratio: function(a, b) {
return (sortDirection ? 1 : -1) * (a.getRatio() - b.getRatio());
}
};

Expand Down Expand Up @@ -600,14 +603,14 @@ class Asset extends React.Component {
noPopOver
/>)</span> : null}
</th>
<th className="clickable" onClick={this._toggleSortOrder.bind(this, "price")}>
<th className="clickable" onClick={this._toggleSortOrder.bind(this, "ratio")}>
<Translate content="borrow.coll_ratio" />
</th>
</tr>
</thead>
<tbody>
{this.state.callOrders
.sort(filterFunctions[this.state.marginTableSort])
.sort(sortFunctions[this.state.marginTableSort])
.map(c => {
return (
<tr className="margin-row" key={c.id}>
Expand Down

0 comments on commit 49d1138

Please sign in to comment.