mirror of https://github.com/zulip/zulip.git
Send notifications over the JS→C++ bridge if it exists.
When determining if desktop notifications are enabled, we can check whether there is a "window.bridge" element. Now when it comes time to actually send out notifications, we can just test again for the existence of "window.bridge" and if so, shunt the data over it. (imported from commit 8104c91ea9da7bc485c86a3c21edc88905d2f47b)
This commit is contained in:
parent
3ee4161ace
commit
c5d3ca0247
|
@ -13,7 +13,9 @@ function browser_desktop_notifications_on () {
|
|||
// Firefox on Ubuntu claims to do webkitNotifications but its notifications are terrible
|
||||
$.browser.webkit &&
|
||||
// 0 is PERMISSION_ALLOWED
|
||||
window.webkitNotifications.checkPermission() === 0);
|
||||
window.webkitNotifications.checkPermission() === 0) ||
|
||||
// window.bridge is the desktop client
|
||||
(window.bridge !== undefined);
|
||||
}
|
||||
|
||||
exports.initialize = function () {
|
||||
|
@ -132,7 +134,7 @@ function process_desktop_notification(message) {
|
|||
content += " [...]";
|
||||
}
|
||||
|
||||
if (notice_memory[key] !== undefined) {
|
||||
if (window.bridge === undefined && notice_memory[key] !== undefined) {
|
||||
msg_count = notice_memory[key].msg_count + 1;
|
||||
title = msg_count + " messages from " + title;
|
||||
notification_object = notice_memory[key].obj;
|
||||
|
@ -156,6 +158,7 @@ function process_desktop_notification(message) {
|
|||
title += " (to " + message.stream + " > " + message.subject + ")";
|
||||
}
|
||||
|
||||
if (window.bridge === undefined) {
|
||||
notice_memory[key] = {
|
||||
obj: window.webkitNotifications.createNotification(
|
||||
gravatar_url(message), title, content),
|
||||
|
@ -170,6 +173,10 @@ function process_desktop_notification(message) {
|
|||
delete notice_memory[key];
|
||||
};
|
||||
notification_object.show();
|
||||
} else {
|
||||
// Shunt the message along to the desktop client
|
||||
window.bridge.notify({title: title, content: content});
|
||||
}
|
||||
}
|
||||
|
||||
exports.speaking_at_me = function (message) {
|
||||
|
|
Loading…
Reference in New Issue