simplify power save block calls, fix #141
This commit is contained in:
32
main/ipc.js
32
main/ipc.js
@@ -12,7 +12,7 @@ var menu = require('./menu')
|
||||
var windows = require('./windows')
|
||||
|
||||
// has to be a number, not a boolean, and undefined throws an error
|
||||
var powerSaveBlocked = 0
|
||||
var powerSaveBlockID = 0
|
||||
|
||||
function init () {
|
||||
ipcMain.on('showOpenTorrentFile', function (e) {
|
||||
@@ -43,24 +43,12 @@ function init () {
|
||||
windows.main.setTitle(title)
|
||||
})
|
||||
|
||||
ipcMain.on('blockPowerSave', blockPowerSave)
|
||||
ipcMain.on('unblockPowerSave', unblockPowerSave)
|
||||
|
||||
ipcMain.on('log', function (e, message) {
|
||||
console.log(message)
|
||||
})
|
||||
|
||||
ipcMain.on('playing-video', function (e) {
|
||||
powerSaveBlocked = powerSaveBlocker.start('prevent-display-sleep')
|
||||
})
|
||||
|
||||
ipcMain.on('paused-video', function (e) {
|
||||
if (powerSaveBlocker.isStarted(powerSaveBlocked)) {
|
||||
powerSaveBlocker.stop(powerSaveBlocked)
|
||||
}
|
||||
})
|
||||
|
||||
ipcMain.on('openItem', function (e, path) {
|
||||
console.log('opening file or folder: ' + path)
|
||||
electron.shell.openItem(path)
|
||||
})
|
||||
}
|
||||
|
||||
function setBounds (bounds) {
|
||||
@@ -90,3 +78,15 @@ function setProgress (progress) {
|
||||
windows.main.setProgressBar(progress)
|
||||
}
|
||||
}
|
||||
|
||||
function blockPowerSave () {
|
||||
powerSaveBlockID = powerSaveBlocker.start('prevent-display-sleep')
|
||||
debug('blockPowerSave %d', powerSaveBlockID)
|
||||
}
|
||||
|
||||
function unblockPowerSave () {
|
||||
if (powerSaveBlocker.isStarted(powerSaveBlockID)) {
|
||||
powerSaveBlocker.stop(powerSaveBlockID)
|
||||
debug('unblockPowerSave %d', powerSaveBlockID)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user