@@ -1,4 +1,5 @@
|
|||||||
const State = require('../lib/state')
|
const State = require('../lib/state')
|
||||||
|
const {dispatch} = require('../lib/dispatcher')
|
||||||
const ipcRenderer = require('electron').ipcRenderer
|
const ipcRenderer = require('electron').ipcRenderer
|
||||||
|
|
||||||
// Controls the Preferences screen
|
// Controls the Preferences screen
|
||||||
@@ -50,5 +51,6 @@ module.exports = class PrefsController {
|
|||||||
}
|
}
|
||||||
state.saved.prefs = Object.assign(state.saved.prefs || {}, state.unsaved.prefs)
|
state.saved.prefs = Object.assign(state.saved.prefs || {}, state.unsaved.prefs)
|
||||||
State.save(state)
|
State.save(state)
|
||||||
|
dispatch('checkDownloadPath')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const dragDrop = require('drag-drop')
|
|||||||
const electron = require('electron')
|
const electron = require('electron')
|
||||||
const React = require('react')
|
const React = require('react')
|
||||||
const ReactDOM = require('react-dom')
|
const ReactDOM = require('react-dom')
|
||||||
|
const fs = require('fs')
|
||||||
|
|
||||||
const config = require('../config')
|
const config = require('../config')
|
||||||
const App = require('./views/app')
|
const App = require('./views/app')
|
||||||
@@ -74,6 +75,12 @@ function onState (err, _state) {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Calling update() updates the UI given the current state
|
||||||
|
// Do this at least once a second to give every file in every torrentSummary
|
||||||
|
// a progress bar and to keep the cursor in sync when playing a video
|
||||||
|
setInterval(update, 1000)
|
||||||
|
app = ReactDOM.render(<App state={state} />, document.querySelector('#body'))
|
||||||
|
|
||||||
// Restart everything we were torrenting last time the app ran
|
// Restart everything we were torrenting last time the app ran
|
||||||
resumeTorrents()
|
resumeTorrents()
|
||||||
|
|
||||||
@@ -83,11 +90,8 @@ function onState (err, _state) {
|
|||||||
// Listen for messages from the main process
|
// Listen for messages from the main process
|
||||||
setupIpc()
|
setupIpc()
|
||||||
|
|
||||||
// Calling update() updates the UI given the current state
|
// Warn if the download dir is gone, eg b/c an external drive is unplugged
|
||||||
// Do this at least once a second to give every file in every torrentSummary
|
checkDownloadPath()
|
||||||
// a progress bar and to keep the cursor in sync when playing a video
|
|
||||||
setInterval(update, 1000)
|
|
||||||
app = ReactDOM.render(<App state={state} />, document.querySelector('#body'))
|
|
||||||
|
|
||||||
// OS integrations:
|
// OS integrations:
|
||||||
// ...drag and drop files/text to start torrenting or seeding
|
// ...drag and drop files/text to start torrenting or seeding
|
||||||
@@ -212,6 +216,7 @@ const dispatchHandlers = {
|
|||||||
// Preferences screen
|
// Preferences screen
|
||||||
'preferences': () => controllers.prefs.show(),
|
'preferences': () => controllers.prefs.show(),
|
||||||
'updatePreferences': (key, value) => controllers.prefs.update(key, value),
|
'updatePreferences': (key, value) => controllers.prefs.update(key, value),
|
||||||
|
'checkDownloadPath': checkDownloadPath,
|
||||||
|
|
||||||
// Update (check for new versions on Linux, where there's no auto updater)
|
// Update (check for new versions on Linux, where there's no auto updater)
|
||||||
'updateAvailable': (version) => controllers.update.updateAvailable(version),
|
'updateAvailable': (version) => controllers.update.updateAvailable(version),
|
||||||
@@ -433,3 +438,15 @@ function onFullscreenChanged (e, isFullScreen) {
|
|||||||
|
|
||||||
update()
|
update()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkDownloadPath () {
|
||||||
|
state.downloadPathStatus = undefined
|
||||||
|
fs.stat(state.saved.prefs.downloadPath, function (err, stat) {
|
||||||
|
if (err) {
|
||||||
|
state.downloadPathStatus = 'missing'
|
||||||
|
return console.error(err)
|
||||||
|
}
|
||||||
|
if (stat.isDirectory()) state.downloadPathStatus = 'ok'
|
||||||
|
else state.downloadPathStatus = 'missing'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ function renderGeneralSection (state) {
|
|||||||
description: '',
|
description: '',
|
||||||
icon: 'settings'
|
icon: 'settings'
|
||||||
}, [
|
}, [
|
||||||
renderDownloadDirSelector(state),
|
renderDownloadPathSelector(state),
|
||||||
renderFileHandlers(state)
|
renderFileHandlers(state)
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDownloadDirSelector (state) {
|
function renderDownloadPathSelector (state) {
|
||||||
return renderFileSelector({
|
return renderFileSelector({
|
||||||
key: 'download-path',
|
key: 'download-path',
|
||||||
label: 'Download Path',
|
label: 'Download Path',
|
||||||
|
|||||||
@@ -8,16 +8,36 @@ const {dispatcher} = require('../lib/dispatcher')
|
|||||||
module.exports = class TorrentList extends React.Component {
|
module.exports = class TorrentList extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
var state = this.props.state
|
var state = this.props.state
|
||||||
var torrentRows = state.saved.torrents.map(
|
|
||||||
(torrentSummary) => this.renderTorrent(torrentSummary)
|
|
||||||
)
|
|
||||||
|
|
||||||
return (
|
var contents
|
||||||
<div key='torrent-list' className='torrent-list'>
|
if (!state.downloadPathStatus) {
|
||||||
{torrentRows}
|
contents = ''
|
||||||
|
} else if (state.downloadPathStatus === 'missing') {
|
||||||
|
contents = (
|
||||||
|
<div>
|
||||||
|
<p>Download path missing: {state.saved.prefs.downloadPath}</p>
|
||||||
|
<p>Check that all drives are connected?</p>
|
||||||
|
<p>Alternatively, choose a new download path in
|
||||||
|
<a href='#' onClick={dispatcher('preferences')}>Preferences</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
} else if (state.downloadPathStatus === 'ok') {
|
||||||
|
contents = state.saved.torrents.map(
|
||||||
|
(torrentSummary) => this.renderTorrent(torrentSummary)
|
||||||
|
)
|
||||||
|
contents.push(
|
||||||
<div key='torrent-placeholder' className='torrent-placeholder'>
|
<div key='torrent-placeholder' className='torrent-placeholder'>
|
||||||
<span className='ellipsis'>Drop a torrent file here or paste a magnet link</span>
|
<span className='ellipsis'>Drop a torrent file here or paste a magnet link</span>
|
||||||
</div>
|
</div>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
throw new Error('Unhandled downloadPathStatus ' + state.downloadPathStatus)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div key='torrent-list' className='torrent-list'>
|
||||||
|
{contents}
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -551,6 +551,13 @@ input[type='text'] {
|
|||||||
line-height: 1.5em;
|
line-height: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TORRENT LIST: ERRORS
|
||||||
|
*/
|
||||||
|
.torrent-list p {
|
||||||
|
padding: 5px 20px;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TORRENT LIST: DRAG-DROP TARGET
|
* TORRENT LIST: DRAG-DROP TARGET
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user