Refactor main.js: fix state save on exit

This commit is contained in:
DC
2016-07-08 11:20:56 -07:00
parent dfe1e3b631
commit 7050ee849b
3 changed files with 19 additions and 18 deletions

View File

@@ -180,7 +180,6 @@ const dispatchHandlers = {
'deleteTorrent': (infoHash) => controllers.torrentList.deleteTorrent(infoHash),
'toggleSelectTorrent': (infoHash) => controllers.torrentList.toggleSelectTorrent(infoHash),
'openTorrentContextMenu': (infoHash) => controllers.torrentList.openTorrentContextMenu(infoHash),
'startTorrentingSummary': (torrentSummary) =>
controllers.torrentList.startTorrentingSummary(torrentSummary),
@@ -236,9 +235,9 @@ const dispatchHandlers = {
// Everything else
'onOpen': (files) => onOpen(files),
'saveState': (state) => State.save(state),
'onError': (err) => onError(err),
'uncaughtError': (proc, err) => telemetry.logUncaughtError(proc, err)
'uncaughtError': (proc, err) => telemetry.logUncaughtError(proc, err),
'saveState': () => State.save(state)
}
// Events from the UI never modify state directly. Instead they call dispatch()
@@ -284,6 +283,8 @@ function setupIpc () {
ipcRenderer.on('wt-uncaught-error', (e, err) => telemetry.logUncaughtError('webtorrent', err))
ipcRenderer.send('ipcReady')
State.on('savedState', () => ipcRenderer.send('savedState'))
}
// Quits any modal popovers and returns to the torrent list screen