Preferences: fix Make Default

This commit is contained in:
DC
2016-08-30 22:50:44 -07:00
parent ef1bc13c38
commit f528f6033f
2 changed files with 25 additions and 28 deletions

View File

@@ -56,7 +56,9 @@ class CreateTorrentPage extends React.Component {
} }
var maxFileElems = 100 var maxFileElems = 100
var fileElems = files.slice(0, maxFileElems).map(function (file, i) { var fileElems = files.slice(0, maxFileElems).map(function (file, i) {
var relativePath = files.length === 0 ? file.name : path.relative(pathPrefix, file.path) var relativePath = files.length === 0
? file.name
: path.relative(pathPrefix, file.path)
return (<div key={i}>{relativePath}</div>) return (<div key={i}>{relativePath}</div>)
}) })
if (files.length > maxFileElems) { if (files.length > maxFileElems) {
@@ -83,8 +85,6 @@ class CreateTorrentPage extends React.Component {
var options = { var options = {
// We can't let the user choose their own name if we want WebTorrent // We can't let the user choose their own name if we want WebTorrent
// to use the files in place rather than creating a new folder. // to use the files in place rather than creating a new folder.
// If we ever want to add support for that:
// name: document.querySelector('.torrent-name').value
name: this.state.defaultName, name: this.state.defaultName,
path: this.state.basePath, path: this.state.basePath,
files: this.state.files, files: this.state.files,

View File

@@ -96,6 +96,14 @@ class PreferencesPage extends React.Component {
} }
setDefaultAppButton () { setDefaultAppButton () {
var isFileHandler = this.props.state.unsaved.prefs.isFileHandler
if (isFileHandler) {
return (
<Preference>
<p>WebTorrent is your default torrent app. Hooray!</p>
</Preference>
)
}
return ( return (
<Preference> <Preference>
<p>WebTorrent is not currently the default torrent app.</p> <p>WebTorrent is not currently the default torrent app.</p>
@@ -109,20 +117,17 @@ class PreferencesPage extends React.Component {
} }
handleSetDefaultApp () { handleSetDefaultApp () {
window.alert('TODO') dispatch('updatePreferences', 'isFileHandler', true)
// var isFileHandler = state.unsaved.prefs.isFileHandler
// dispatch('updatePreferences', 'isFileHandler', !isFileHandler)
} }
render () { render () {
var style = {
color: colors.grey400,
marginLeft: 25,
marginRight: 25
}
return ( return (
<div <div style={style} >
style={{
color: colors.grey400,
marginLeft: 25,
marginRight: 25
}}
>
<PreferencesSection title='Downloads'> <PreferencesSection title='Downloads'>
{this.downloadPathSelector()} {this.downloadPathSelector()}
</PreferencesSection> </PreferencesSection>
@@ -146,13 +151,12 @@ class PreferencesSection extends React.Component {
} }
render () { render () {
var style = {
marginBottom: 25,
marginTop: 25
}
return ( return (
<div <div style={style}>
style={{
marginBottom: 25,
marginTop: 25
}}
>
<Heading level={2}>{this.props.title}</Heading> <Heading level={2}>{this.props.title}</Heading>
{this.props.children} {this.props.children}
</div> </div>
@@ -162,15 +166,8 @@ class PreferencesSection extends React.Component {
class Preference extends React.Component { class Preference extends React.Component {
render () { render () {
return ( var style = { marginBottom: 10 }
<div return (<div style={style}>{this.props.children}</div>)
style={{
marginBottom: 10
}}
>
{this.props.children}
</div>
)
} }
} }