mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-05 04:47:54 +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) {
|
||||
mainWindow.on('page-title-updated', () => {
|
||||
if (mainWindow.isFocused()) {
|
||||
mainWindow.on('page-title-updated', (e, title) => {
|
||||
const itemCountRegex = /[\(\[{](\d*?)[}\]\)]/;
|
||||
const match = itemCountRegex.exec(title);
|
||||
if (match) {
|
||||
setDockBadge(match[1]);
|
||||
} else {
|
||||
setDockBadge('');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ipcMain.on('notification', () => {
|
||||
if (!isOSX() || mainWindow.isFocused()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (options.counter) {
|
||||
const itemCountRegex = /[\(\[{](\d*?)[}\]\)]/;
|
||||
const match = itemCountRegex.exec(mainWindow.getTitle());
|
||||
if (match) {
|
||||
setDockBadge(match[1]);
|
||||
}
|
||||
return;
|
||||
}
|
||||
setDockBadge('●');
|
||||
setDockBadge('•');
|
||||
});
|
||||
mainWindow.on('focus', () => {
|
||||
setDockBadge('');
|
||||
});
|
||||
}
|
||||
|
||||
@ -168,10 +172,6 @@ function createMainWindow(options, onAppQuit, setDockBadge) {
|
||||
|
||||
mainWindow.loadURL(options.targetUrl);
|
||||
|
||||
mainWindow.on('focus', () => {
|
||||
setDockBadge('');
|
||||
});
|
||||
|
||||
mainWindow.on('close', event => {
|
||||
if (mainWindow.isFullScreen()) {
|
||||
mainWindow.setFullScreen(false);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import 'source-map-support/register';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import {app, ipcMain, crashReporter} from 'electron';
|
||||
import {app, crashReporter} from 'electron';
|
||||
import createLoginWindow from './components/login/loginWindow';
|
||||
import createMainWindow from './components/mainWindow/mainWindow';
|
||||
import helpers from './helpers/helpers';
|
||||
@ -81,10 +81,3 @@ app.on('login', (event, webContents, request, authInfo, callback) => {
|
||||
event.preventDefault();
|
||||
createLoginWindow(callback);
|
||||
});
|
||||
|
||||
ipcMain.on('notification', () => {
|
||||
if (!isOSX() || mainWindow.isFocused()) {
|
||||
return;
|
||||
}
|
||||
setDockBadge('●');
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user