Cleanup for PR #571

This commit is contained in:
Feross Aboukhadijeh
2016-05-23 15:15:52 -07:00
parent 2dafc68301
commit 30e81c7699
2 changed files with 9 additions and 12 deletions

View File

@@ -193,8 +193,14 @@ function TorrentList (state) {
filesElement = hx`<div class='files warning'>${message}</div>`
} else {
// We do know the files. List them and show download stats for each one
var fileRows = torrentSummary.files.sort(fileSortHelper).map(
(file, index) => renderFileRow(torrentSummary, file, index))
var fileRows = torrentSummary.files
.sort(function (a, b) {
if (a.name < b.name) return -1
if (b.name < a.name) return 1
return 0
})
.map((file, index) => renderFileRow(torrentSummary, file, index))
filesElement = hx`
<div class='files'>
<table>
@@ -211,15 +217,6 @@ function TorrentList (state) {
`
}
function fileSortHelper (a, b) {
var result = 0
if (a.name > b.name) {
result = 1
} else if (a.name < b.name) {
result = -1
}
return result
}
// Show a single torrentSummary file in the details view for a single torrent
function renderFileRow (torrentSummary, file, index) {
// First, find out how much of the file we've downloaded