2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-11-11 07:41:04 +00:00

Merge branch 'development' of https://github.com/thomsbg/nativefier into thomsbg-development

# Conflicts:
#	app/src/main.js
This commit is contained in:
Goh Jia Hao 2016-10-09 14:01:02 +08:00
commit b85bde4963
2 changed files with 17 additions and 24 deletions

View File

@ -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);

View File

@ -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('●');
});