diff --git a/models/client.js b/models/client.js
index 981e58de..26d88ae6 100644
--- a/models/client.js
+++ b/models/client.js
@@ -170,27 +170,33 @@ client.prototype.getTorrentList = function(callback) {
var hours = Math.floor((((seconds % 31536000) % 604800) % 86400) / 3600);
var minutes = Math.floor(((((seconds % 31536000) % 604800) % 86400) % 3600) / 60);
var wholeSeconds = Math.floor((((((seconds % 31536000) % 604800) % 86400) % 3600) % 60) / 60);
+
var timeRemaining = {};
+ seconds = Math.floor(seconds);
if (years > 0) {
timeRemaining = {
years: years,
- weeks: weeks
+ weeks: weeks,
+ seconds: seconds
}
} else if (weeks > 0) {
timeRemaining = {
weeks: weeks,
- days: days
+ days: days,
+ seconds: seconds
}
} else if (days > 0) {
timeRemaining = {
days: days,
- hours: hours
+ hours: hours,
+ seconds: seconds
}
} else if (hours > 0) {
timeRemaining = {
hours: hours,
- minutes: minutes
+ minutes: minutes,
+ seconds: seconds
}
} else if (minutes > 0) {
timeRemaining = {
diff --git a/source/scripts/components/torrent-list/TorrentListHeader.js b/source/scripts/components/torrent-list/TorrentListHeader.js
index 3d6f3f5f..fdf5694a 100644
--- a/source/scripts/components/torrent-list/TorrentListHeader.js
+++ b/source/scripts/components/torrent-list/TorrentListHeader.js
@@ -52,7 +52,7 @@ var TorrentListHeader = React.createClass({
-
+
diff --git a/source/scripts/stores/TorrentStore.js b/source/scripts/stores/TorrentStore.js
index 94cc36e3..154091be 100644
--- a/source/scripts/stores/TorrentStore.js
+++ b/source/scripts/stores/TorrentStore.js
@@ -124,34 +124,54 @@ var sortTorrentList = function() {
var sortedList = _torrents.sort(function(a, b) {
- var propA = a[property];
- var propB = b[property];
+ var valA = a[property];
+ var valB = b[property];
- if (property === 'name') {
- propA = propA.toLowerCase();
- propB = propB.toLowerCase();
+ if (property === 'eta') {
+
+ // keep infinity at bottom of array when sorting by eta
+ if (valA === 'Infinity' && valB !== 'Infinity') {
+ return 1;
+ } else if (valA !== 'Infinity' && valB === 'Infinity') {
+ return -1;
+ }
+
+ // if it's not infinity, compare the second as numbers
+ if (valA !== 'Infinity') {
+ valA = Number(valA.seconds);
+ }
+
+ if (valB !== 'Infinity') {
+ valB = Number(valB.seconds);
+ }
+
+ } else if (property === 'name') {
+
+ valA = valA.toLowerCase();
+ valB = valB.toLowerCase();
} else {
- propA = Number(propA);
- propB = Number(propB);
+
+ valA = Number(valA);
+ valB = Number(valB);
}
if (direction === 'asc') {
- if (propA > propB) {
+ if (valA > valB) {
return 1;
}
- if (propA < propB) {
+ if (valA < valB) {
return -1;
}
} else {
- if (propA > propB) {
+ if (valA > valB) {
return -1;
}
- if (propA < propB) {
+ if (valA < valB) {
return 1;
}