Merge pull request #1498 from webtorrent/cleanup-preferences
Cleanup preferences page
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
const path = require('path')
|
||||
|
||||
const colors = require('material-ui/styles/colors')
|
||||
const electron = require('electron')
|
||||
const React = require('react')
|
||||
@@ -16,7 +18,6 @@ class PathSelector extends React.Component {
|
||||
return {
|
||||
className: PropTypes.string,
|
||||
dialog: PropTypes.object,
|
||||
displayValue: PropTypes.string,
|
||||
id: PropTypes.string,
|
||||
onChange: PropTypes.func,
|
||||
title: PropTypes.string.isRequired,
|
||||
@@ -31,7 +32,7 @@ class PathSelector extends React.Component {
|
||||
|
||||
handleClick () {
|
||||
const opts = Object.assign({
|
||||
defaultPath: this.props.value,
|
||||
defaultPath: this.props.value && path.dirname(this.props.value),
|
||||
properties: ['openFile', 'openDirectory']
|
||||
}, this.props.dialog)
|
||||
|
||||
@@ -65,8 +66,7 @@ class PathSelector extends React.Component {
|
||||
const textFieldStyle = {
|
||||
flex: '1'
|
||||
}
|
||||
|
||||
const text = this.props.displayValue || this.props.value || ''
|
||||
const text = this.props.value || ''
|
||||
const buttonStyle = {
|
||||
marginLeft: 10
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
const path = require('path')
|
||||
const React = require('react')
|
||||
const PropTypes = require('prop-types')
|
||||
|
||||
@@ -102,10 +101,9 @@ class PreferencesPage extends React.Component {
|
||||
title: 'Select media player app',
|
||||
properties: ['openFile']
|
||||
}}
|
||||
displayValue={playerName}
|
||||
onChange={this.handleExternalPlayerPathChange}
|
||||
title='External player'
|
||||
value={playerPath ? path.dirname(playerPath) : null}
|
||||
value={playerPath}
|
||||
/>
|
||||
</Preference>
|
||||
)
|
||||
@@ -139,11 +137,11 @@ class PreferencesPage extends React.Component {
|
||||
dispatch('updatePreferences', 'autoAddTorrents', isChecked)
|
||||
|
||||
if (isChecked) {
|
||||
dispatch('startFolderWatcher', null)
|
||||
dispatch('startFolderWatcher')
|
||||
return
|
||||
}
|
||||
|
||||
dispatch('stopFolderWatcher', null)
|
||||
dispatch('stopFolderWatcher')
|
||||
}
|
||||
|
||||
torrentsFolderPathSelector () {
|
||||
@@ -156,10 +154,9 @@ class PreferencesPage extends React.Component {
|
||||
title: 'Select folder to watch for new torrents',
|
||||
properties: ['openDirectory']
|
||||
}}
|
||||
displayValue={torrentsFolderPath || ''}
|
||||
onChange={this.handleTorrentsFolderPathChange}
|
||||
title='Folder to watch'
|
||||
value={torrentsFolderPath ? path.dirname(torrentsFolderPath) : null}
|
||||
value={torrentsFolderPath}
|
||||
/>
|
||||
</Preference>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user