Draw attention to the window on new messages

// FREEBIE
This commit is contained in:
lilia 2017-04-24 17:14:38 -07:00 committed by Scott Nonnenberg
parent ea930d53ae
commit 0c9cca08ba
No known key found for this signature in database
GPG key ID: A4931C09644C654B
3 changed files with 19 additions and 11 deletions

View file

@ -13,16 +13,6 @@
return true;
};
window.drawAttention = function() {
if (isOpen() && !isFocused()) {
if (window.keepClear) {
clearInterval(window.keepClear);
delete window.keepClear;
}
console.log('draw attention');
extension.windows.drawAttention(inboxWindowId);
}
};
window.clearAttention = function() {
console.log('clear attention');
if (window.keepClear) {

16
main.js
View file

@ -76,7 +76,11 @@ function createWindow () {
//sandbox: true,
preload: path.join(__dirname, 'preload.js')
}
})
});
mainWindow.on('focus', function() {
mainWindow.flashFrame(false);
});
// Load locale
const locale = 'en'; // FIXME
@ -177,3 +181,13 @@ app.on('activate', function () {
ipc.on('set-badge-count', function(event, count) {
app.setBadgeCount(count);
});
ipc.on('draw-attention', function(event, count) {
if (process.platform === 'darwin') {
app.dock.bounce();
} else if (process.platform == 'win32') {
mainWindow.flashFrame(true);
setTimeout(function() {
mainWindow.flashFrame(false);
}, 1000);
}
});

View file

@ -11,6 +11,10 @@
window.setBadgeCount = function(count) {
ipc.send('set-badge-count', count);
};
window.drawAttention = function() {
console.log('draw attention');
ipc.send('draw-attention');
};
/**
* Enables spell-checking and the right-click context menu in text editors.
* Electron (`webFrame.setSpellCheckProvider`) only underlines misspelled words;