Add context menu option to toggle Sort by Name
This commit is contained in:
@@ -279,6 +279,16 @@ module.exports = class TorrentListController {
|
|||||||
enabled: torrentSummary.torrentFileName != null
|
enabled: torrentSummary.torrentFileName != null
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
menu.append(new electron.remote.MenuItem({
|
||||||
|
type: 'separator'
|
||||||
|
}))
|
||||||
|
|
||||||
|
const sortedByName = this.state.saved.prefs.sortByName
|
||||||
|
menu.append(new electron.remote.MenuItem({
|
||||||
|
label: `${sortedByName ? '✓ ' : ''}Sort by Name`,
|
||||||
|
click: () => dispatch('updatePreferences', 'sortByName', !sortedByName)
|
||||||
|
}))
|
||||||
|
|
||||||
menu.popup(electron.remote.getCurrentWindow())
|
menu.popup(electron.remote.getCurrentWindow())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -279,12 +279,17 @@ module.exports = class TorrentList extends React.Component {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// We do know the files. List them and show download stats for each one
|
// 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 sorter = natsort()
|
||||||
const fileRows = torrentSummary.files
|
let fileRows = torrentSummary.files
|
||||||
.filter((file) => !file.path.includes('/.____padding_file/'))
|
.filter((file) => !file.path.includes('/.____padding_file/'))
|
||||||
.map((file, index) => ({ file, index }))
|
.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 = (
|
filesElement = (
|
||||||
<div key='files' className='files'>
|
<div key='files' className='files'>
|
||||||
|
|||||||
Reference in New Issue
Block a user