Skip to content

Instantly share code, notes, and snippets.

@cfsilence
Created April 10, 2018 03:46
Show Gist options
  • Save cfsilence/b0553b0371fea240382a8563c5577afd to your computer and use it in GitHub Desktop.
Save cfsilence/b0553b0371fea240382a8563c5577afd to your computer and use it in GitHub Desktop.
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