Clean up thumbar (thumbnail) code (#670)

* Cleanup thumbnail bar code

- rename thumbnail method names for succinctness
- Get rid of 'updateThumbnailBar' event -- use existing events
- Get rid of 'blockPowerSave' and 'unblockPowerSave' events -- use a
new combined 'onPlayerPlay' and 'onPlayerPause' events which apply to
power save and updating the thumbbar

* Consistent naming for enable/disable methods
This commit is contained in:
Feross Aboukhadijeh
2016-06-28 06:32:28 -07:00
committed by DC
parent c44943cef7
commit 349c5ee22e
7 changed files with 81 additions and 68 deletions

View File

@@ -1,6 +1,6 @@
module.exports = {
start,
stop
enable,
disable
}
var electron = require('electron')
@@ -12,19 +12,19 @@ var blockId = 0
* Block the system from entering low-power (sleep) mode or turning off the
* display.
*/
function start () {
stop() // Stop the previous power saver block, if one exists.
function enable () {
disable() // Stop the previous power saver block, if one exists.
blockId = electron.powerSaveBlocker.start('prevent-display-sleep')
log(`powerSaveBlocker.start: ${blockId}`)
log(`powerSaveBlocker.enable: ${blockId}`)
}
/**
* Stop blocking the system from entering low-power mode.
*/
function stop () {
function disable () {
if (!electron.powerSaveBlocker.isStarted(blockId)) {
return
}
electron.powerSaveBlocker.stop(blockId)
log(`powerSaveBlocker.stop: ${blockId}`)
log(`powerSaveBlocker.disable: ${blockId}`)
}