[Git][noosfero/noosfero][cherry-pick-3757c1d9] Merge branch 'chat-notification' into 'master'
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Oct 24 15:22:14 BRST 2016
Rodrigo Souto pushed to branch cherry-pick-3757c1d9 at Noosfero / noosfero
Commits:
22e2f638 by Rodrigo Souto at 2016-10-24T17:22:00+00:00
Merge branch 'chat-notification' into 'master'
chat: avoid notification crash on browsers that does not support it
See merge request !1031
- - - - -
2 changed files:
- public/javascripts/application.js
- public/javascripts/chat.js
Changes:
=====================================
public/javascripts/application.js
=====================================
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1130,12 +1130,10 @@ function apply_zoom_to_images(zoom_text) {
}
function notifyMe(title, options) {
- // This might be useful in the future
- //
// Let's check if the browser supports notifications
- // if (!("Notification" in window)) {
- // alert("This browser does not support desktop notification");
- // }
+ if (!("Notification" in window)) {
+ return null;
+ }
// Let's check if the user is okay to get some notification
var notification = null;
=====================================
public/javascripts/chat.js
=====================================
--- a/public/javascripts/chat.js
+++ b/public/javascripts/chat.js
@@ -493,7 +493,7 @@ jQuery(function($) {
},
connect: function() {
- if (Notification.permission !== "granted" && Notification.permission !== "denied") {
+ if (("Notification" in window) && Notification.permission !== "granted" && Notification.permission !== "denied") {
Notification.requestPermission(function (permission) {
if (!('permission' in Notification)) {
Notification.permission = permission;
@@ -874,6 +874,8 @@ jQuery(function($) {
}
function notifyMessage(message) {
+ if(!("Notification" in window))
+ return null;
var jid = Strophe.getBareJidFromJid(message.from);
var jid_id = Jabber.jid_to_id(jid);
var name = Jabber.name_of(jid_id);
View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/22e2f63826f240dd52eb409a8e6c857835467a12
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20161024/d51fb6ce/attachment-0001.html>
More information about the Noosfero-dev
mailing list