Created
April 10, 2018 03:46
-
-
Save cfsilence/b0553b0371fea240382a8563c5577afd to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
notifyMessage(message: Message):void { | |
// don't notify the user of messages they sent | |
// and only show a notification if the application | |
// isn't visible (IE: it is minimized) | |
if( message.author === this.currentUsername || !this.showDesktopNotification ) { | |
return; | |
} | |
const notification = { | |
title: `TWACK Message from ${message.author}`, | |
body: message.body | |
} | |
const desktopNotification = new Notification(notification.title, notification); | |
// the following click handler is not fired | |
// in Debian 9 running KDE (seems to be an OS bug) | |
// but tested and works in macOS High Sierra | |
desktopNotification.onclick = () => { | |
const win = window.require('electron').remote.getCurrentWindow(); | |
win.restore(); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment