clean up preferences-page

This commit is contained in:
Mathias Rasmussen
2018-09-28 17:10:21 +02:00
parent caceeee238
commit f231c54886
2 changed files with 8 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
const path = require('path')
const colors = require('material-ui/styles/colors') const colors = require('material-ui/styles/colors')
const electron = require('electron') const electron = require('electron')
const React = require('react') const React = require('react')
@@ -31,8 +33,8 @@ class PathSelector extends React.Component {
handleClick () { handleClick () {
const opts = Object.assign({ const opts = Object.assign({
defaultPath: this.props.value, defaultPath: this.props.value && path.dirname(this.props.value),
properties: ['openFile', 'openDirectory'] properties: [ 'openFile', 'openDirectory' ]
}, this.props.dialog) }, this.props.dialog)
remote.dialog.showOpenDialog( remote.dialog.showOpenDialog(

View File

@@ -1,4 +1,3 @@
const path = require('path')
const React = require('react') const React = require('react')
const PropTypes = require('prop-types') const PropTypes = require('prop-types')
@@ -105,7 +104,7 @@ class PreferencesPage extends React.Component {
displayValue={playerName} displayValue={playerName}
onChange={this.handleExternalPlayerPathChange} onChange={this.handleExternalPlayerPathChange}
title='External player' title='External player'
value={playerPath ? path.dirname(playerPath) : null} value={playerPath}
/> />
</Preference> </Preference>
) )
@@ -139,11 +138,11 @@ class PreferencesPage extends React.Component {
dispatch('updatePreferences', 'autoAddTorrents', isChecked) dispatch('updatePreferences', 'autoAddTorrents', isChecked)
if (isChecked) { if (isChecked) {
dispatch('startFolderWatcher', null) dispatch('startFolderWatcher')
return return
} }
dispatch('stopFolderWatcher', null) dispatch('stopFolderWatcher')
} }
torrentsFolderPathSelector () { torrentsFolderPathSelector () {
@@ -156,10 +155,9 @@ class PreferencesPage extends React.Component {
title: 'Select folder to watch for new torrents', title: 'Select folder to watch for new torrents',
properties: ['openDirectory'] properties: ['openDirectory']
}} }}
displayValue={torrentsFolderPath || ''}
onChange={this.handleTorrentsFolderPathChange} onChange={this.handleTorrentsFolderPathChange}
title='Folder to watch' title='Folder to watch'
value={torrentsFolderPath ? path.dirname(torrentsFolderPath) : null} value={torrentsFolderPath}
/> />
</Preference> </Preference>
) )