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 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>)
})
if (files.length > maxFileElems) {
@@ -83,8 +85,6 @@ class CreateTorrentPage extends React.Component {
var options = {
// 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.
// If we ever want to add support for that:
// name: document.querySelector('.torrent-name').value
name: this.state.defaultName,
path: this.state.basePath,
files: this.state.files,

View File

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