mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-02-03 20:28:24 +00:00
Fix counter notifications (#256)
- Merge branch 'thomsbg-development' into development
This commit is contained in:
commit
026fb45d19
@ -136,20 +136,24 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (options.counter) {
|
if (options.counter) {
|
||||||
mainWindow.on('page-title-updated', () => {
|
mainWindow.on('page-title-updated', (e, title) => {
|
||||||
if (mainWindow.isFocused()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.counter) {
|
|
||||||
const itemCountRegex = /[\(\[{](\d*?)[}\]\)]/;
|
const itemCountRegex = /[\(\[{](\d*?)[}\]\)]/;
|
||||||
const match = itemCountRegex.exec(mainWindow.getTitle());
|
const match = itemCountRegex.exec(title);
|
||||||
if (match) {
|
if (match) {
|
||||||
setDockBadge(match[1]);
|
setDockBadge(match[1]);
|
||||||
|
} else {
|
||||||
|
setDockBadge('');
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ipcMain.on('notification', () => {
|
||||||
|
if (!isOSX() || mainWindow.isFocused()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setDockBadge('●');
|
setDockBadge('•');
|
||||||
|
});
|
||||||
|
mainWindow.on('focus', () => {
|
||||||
|
setDockBadge('');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,10 +172,6 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
|||||||
|
|
||||||
mainWindow.loadURL(options.targetUrl);
|
mainWindow.loadURL(options.targetUrl);
|
||||||
|
|
||||||
mainWindow.on('focus', () => {
|
|
||||||
setDockBadge('');
|
|
||||||
});
|
|
||||||
|
|
||||||
mainWindow.on('close', event => {
|
mainWindow.on('close', event => {
|
||||||
if (mainWindow.isFullScreen()) {
|
if (mainWindow.isFullScreen()) {
|
||||||
mainWindow.setFullScreen(false);
|
mainWindow.setFullScreen(false);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'source-map-support/register';
|
import 'source-map-support/register';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {app, ipcMain, crashReporter} from 'electron';
|
import {app, crashReporter} from 'electron';
|
||||||
import createLoginWindow from './components/login/loginWindow';
|
import createLoginWindow from './components/login/loginWindow';
|
||||||
import createMainWindow from './components/mainWindow/mainWindow';
|
import createMainWindow from './components/mainWindow/mainWindow';
|
||||||
import helpers from './helpers/helpers';
|
import helpers from './helpers/helpers';
|
||||||
@ -81,10 +81,3 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
|
|||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
createLoginWindow(callback);
|
createLoginWindow(callback);
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on('notification', () => {
|
|
||||||
if (!isOSX() || mainWindow.isFocused()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setDockBadge('●');
|
|
||||||
});
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user