Introduce library for notifications on downlevel windows (#1812)

This commit is contained in:
Scott Nonnenberg 2017-11-22 13:50:52 -08:00 committed by GitHub
parent be2d4535a8
commit 16ad94148a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 7 deletions

View file

@ -1,6 +1,7 @@
/*
* vim: ts=4:sw=4:expandtab
*/
;(function() {
'use strict';
window.Whisper = window.Whisper || {};
@ -84,14 +85,26 @@
iconUrl = last.get('iconUrl');
break;
}
var notification = new Notification(title, {
body : message,
icon : iconUrl,
tag : 'signal',
silent : true
});
notification.onclick = this.onClick.bind(this, last.get('conversationId'));
if (windows.config.polyfillNotifications) {
window.nodeNotifier.notify({
title: title,
message: message,
sound: false
});
window.nodeNotifier.on('click', function(notifierObject, options) {
last.get('conversationId');
});
} else {
var notification = new Notification(title, {
body : message,
icon : iconUrl,
tag : 'signal',
silent : true
});
notification.onclick = this.onClick.bind(this, last.get('conversationId'));
}
// We don't want to notify the user about these same messages again
this.clear();