Refactor main.js: controllers.playback.skip() (#706)

* Fixes bug with Step Forward/Backward commands not working

* Fix 'invalid torrent identifier' error
This commit is contained in:
Adam Gotlib
2016-07-08 05:27:05 +02:00
committed by DC
parent a373141a93
commit 50c47dd657
5 changed files with 36 additions and 28 deletions

View File

@@ -86,6 +86,11 @@ module.exports = class PlaybackController {
ipcRenderer.send('onPlayerPause')
}
// Skip specified number of seconds (backwards if negative)
skip (time) {
this.skipTo(this.state.playing.currentTime + time)
}
// Skip (aka seek) to a specific point, in seconds
skipTo (time) {
if (isCasting(this.state)) Cast.seek(time)

View File

@@ -65,12 +65,30 @@ module.exports = class TorrentListController {
})
}
// Starts downloading and/or seeding a given torrentSummary.
startTorrentingSummary (torrentSummary) {
var s = torrentSummary
// Backward compatibility for config files save before we had torrentKey
if (!s.torrentKey) s.torrentKey = this.state.nextTorrentKey++
// Use Downloads folder by default
if (!s.path) s.path = this.state.saved.prefs.downloadPath
ipcRenderer.send('wt-start-torrenting',
s.torrentKey,
TorrentSummary.getTorrentID(s),
s.path,
s.fileModtimes,
s.selections)
}
// TODO: use torrentKey, not infoHash
toggleTorrent (infoHash) {
var torrentSummary = TorrentSummary.getByKey(this.state, infoHash)
if (torrentSummary.status === 'paused') {
torrentSummary.status = 'new'
ipcRenderer.send('wt-start-torrenting', torrentSummary)
this.startTorrentingSummary(torrentSummary)
sound.play('ENABLE')
} else {
torrentSummary.status = 'paused'