Fix error on Windows caused by setBadge (#867)

This commit is contained in:
Adam Gotlib
2016-09-02 01:00:57 +02:00
committed by DC
parent df16b14586
commit 14102ab3e6

View File

@@ -4,9 +4,7 @@ module.exports = {
setBadge setBadge
} }
var electron = require('electron') var {app, Menu} = require('electron')
var app = electron.app
var dialog = require('./dialog') var dialog = require('./dialog')
var log = require('./log') var log = require('./log')
@@ -16,7 +14,7 @@ var log = require('./log')
*/ */
function init () { function init () {
if (!app.dock) return if (!app.dock) return
var menu = electron.Menu.buildFromTemplate(getMenuTemplate()) var menu = Menu.buildFromTemplate(getMenuTemplate())
app.dock.setMenu(menu) app.dock.setMenu(menu)
} }
@@ -33,8 +31,11 @@ function downloadFinished (path) {
* Display a counter badge for the app. (Mac, Linux) * Display a counter badge for the app. (Mac, Linux)
*/ */
function setBadge (count) { function setBadge (count) {
if (process.platform === 'darwin' ||
process.platform === 'linux' && app.isUnityRunning()) {
log(`setBadge: ${count}`) log(`setBadge: ${count}`)
app.setBadgeCount(Number(count)) app.setBadgeCount(Number(count))
}
} }
function getMenuTemplate () { function getMenuTemplate () {