Add context menu option to toggle Sort by Name

This commit is contained in:
David Ernst
2019-05-04 22:39:27 -07:00
parent 2dc2953831
commit 2466b2e0a6
2 changed files with 18 additions and 3 deletions

View File

@@ -279,12 +279,17 @@ module.exports = class TorrentList extends React.Component {
)
} else {
// We do know the files. List them and show download stats for each one
const sortByName = this.props.state.saved.prefs.sortByName
const sorter = natsort()
const fileRows = torrentSummary.files
let fileRows = torrentSummary.files
.filter((file) => !file.path.includes('/.____padding_file/'))
.map((file, index) => ({ file, index }))
.sort((a, b) => sorter(a.file.name, b.file.name))
.map((object) => this.renderFileRow(torrentSummary, object.file, object.index))
if (sortByName) {
fileRows = fileRows.sort((a, b) => sorter(a.file.name, b.file.name))
}
fileRows = fileRows.map((object) => this.renderFileRow(torrentSummary, object.file, object.index))
filesElement = (
<div key='files' className='files'>