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

@@ -181,11 +181,13 @@ const dispatchHandlers = {
'toggleSelectTorrent': (infoHash) => controllers.torrentList.toggleSelectTorrent(infoHash),
'openTorrentContextMenu': (infoHash) => controllers.torrentList.openTorrentContextMenu(infoHash),
'startTorrentingSummary': startTorrentingSummary,
'startTorrentingSummary': (torrentSummary) =>
controllers.torrentList.startTorrentingSummary(torrentSummary),
// Playback
'playFile': (infoHash, index) => controllers.playback.playFile(infoHash, index),
'playPause': () => controllers.playback.playPause(),
'skip': (time) => controllers.playback.skip(time),
'skipTo': (time) => controllers.playback.skipTo(time),
'changePlaybackRate': (dir) => controllers.playback.changePlaybackRate(dir),
'changeVolume': (delta) => controllers.playback.changeVolume(delta),
@@ -317,7 +319,7 @@ function escapeBack () {
function resumeTorrents () {
state.saved.torrents
.filter((torrentSummary) => torrentSummary.status !== 'paused')
.forEach((torrentSummary) => startTorrentingSummary(torrentSummary))
.forEach((torrentSummary) => controllers.torrentList.startTorrentingSummary(torrentSummary))
}
function isTorrent (file) {
@@ -333,19 +335,6 @@ function getTorrentSummary (torrentKey) {
return TorrentSummary.getByKey(state, torrentKey)
}
// Starts downloading and/or seeding a given torrentSummary. Returns WebTorrent object
function startTorrentingSummary (torrentSummary) {
var s = torrentSummary
// Backward compatibility for config files save before we had torrentKey
if (!s.torrentKey) s.torrentKey = state.nextTorrentKey++
// Use Downloads folder by default
if (!s.path) s.path = state.saved.prefs.downloadPath
ipcRenderer.send('wt-start-torrenting', s)
}
function torrentInfoHash (torrentKey, infoHash) {
var torrentSummary = getTorrentSummary(torrentKey)
console.log('got infohash for %s torrent %s',