Skip to content

Commit

Permalink
Add badge count for unity linux and use new api for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
princejwesley committed Jul 7, 2016
1 parent 3018cee commit 8af2b48
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"del": "^2.0.2",
"devtron": "^1.0.0",
"electron-packager": "5.1.0",
"electron-prebuilt": "^1.1.0",
"electron-prebuilt": "^1.2.6",
"electron-rebuild": "https://github.com/princejwesley/electron-rebuild.git",
"gulp": "^3.9.0",
"gulp-babel": "^6.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/components/Repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export default class Repl extends React.Component {

onConsoleChange(type) {
let currentWindow = remote.getCurrentWindow();
if(!currentWindow.isFocused() && process.platform === 'darwin') {
if(!currentWindow.isFocused()) {
ipcRenderer.send('application:dock-message-notification', currentWindow.id);
}
if(this.state.showConsole) { return; }
Expand Down
12 changes: 9 additions & 3 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,10 @@ app.on('browser-window-blur', (event, window) => window.$focus = false);
app.on('browser-window-focus', (event, window) => {
window.$focus = true;
dockNotificationCache[window.id] = 0;
if (process.platform === 'darwin') {
app.dock.setBadge('');
if (process.platform === 'darwin' ||
(process.platform === 'linux' &&
app.isUnityRunning())) {
app.setBadgeCount(0);
}
});

Expand Down Expand Up @@ -389,8 +391,12 @@ ipcMain.on('application:download', function(event, buffer) {

ipcMain.on('application:dock-message-notification', function(event, id) {
dockNotificationCache[id] = dockNotificationCache[id] + 1;
if (process.platform === 'darwin' ||
(process.platform === 'linux' &&
app.isUnityRunning())) {
app.setBadgeCount(dockNotificationCache[id]);
}
if (process.platform === 'darwin') {
app.dock.setBadge(`${dockNotificationCache[id]}`);
app.dock.bounce();
}
});
Expand Down

0 comments on commit 8af2b48

Please sign in to comment.