mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-22 22:58:33 +00:00
Fix error with badge on non-osx systems
- Instead of checking every instance we use the setBadge, we define an empty function and only override it if it is OSX
This commit is contained in:
parent
5a04a9886e
commit
c143b3b461
@ -13,8 +13,8 @@ const ZOOM_INTERVAL = 0.1;
|
||||
/**
|
||||
*
|
||||
* @param {{}} options AppArgs from nativefier.json
|
||||
* @param {electron.app.quit} onAppQuit
|
||||
* @param {electron.app.dock.setBadge} setDockBadge
|
||||
* @param {function} onAppQuit
|
||||
* @param {function} setDockBadge
|
||||
* @returns {electron.BrowserWindow}
|
||||
*/
|
||||
function createMainWindow(options, onAppQuit, setDockBadge) {
|
||||
@ -57,7 +57,7 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
||||
if (options.counter) {
|
||||
mainWindow.on('page-title-updated', function () {
|
||||
|
||||
if (!isOSX() || mainWindow.isFocused()) {
|
||||
if (mainWindow.isFocused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -85,10 +85,6 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
||||
mainWindow.loadURL(options.targetUrl);
|
||||
|
||||
mainWindow.on('focus', function () {
|
||||
if (!isOSX()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setDockBadge('');
|
||||
});
|
||||
|
||||
|
@ -5,7 +5,7 @@ var shell = electron.shell;
|
||||
/**
|
||||
*
|
||||
* @param {string} nativefierVersion
|
||||
* @param {electron.app.quit} onQuit should be from app.quit
|
||||
* @param {function} onQuit should be from app.quit
|
||||
* @param {function} onGoBack
|
||||
* @param {electron} onGoForward
|
||||
* @param {function} onZoomIn
|
||||
|
@ -19,6 +19,12 @@ var appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
|
||||
|
||||
var mainWindow;
|
||||
|
||||
// do nothing for setDockBadge if not OSX
|
||||
let setDockBadge = () => {};
|
||||
if (isOSX()) {
|
||||
setDockBadge = app.dock.setBadge;
|
||||
}
|
||||
|
||||
app.on('window-all-closed', function () {
|
||||
if (!isOSX()) {
|
||||
app.quit();
|
||||
@ -47,7 +53,7 @@ app.on('before-quit', function () {
|
||||
});
|
||||
|
||||
app.on('ready', function () {
|
||||
mainWindow = createMainWindow(appArgs, app.quit, app.dock.setBadge);
|
||||
mainWindow = createMainWindow(appArgs, app.quit, setDockBadge);
|
||||
});
|
||||
|
||||
app.on('login', function(event, webContents, request, authInfo, callback) {
|
||||
@ -61,5 +67,5 @@ ipcMain.on('notification', function(event, title, opts) {
|
||||
return;
|
||||
}
|
||||
|
||||
app.dock.setBadge('●');
|
||||
setDockBadge('●');
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user