[Git][noosfero/noosfero][stable-1.6] 2 commits: Merge branch 'chat-notification' into 'master'

Rodrigo Souto gitlab at mg.gitlab.com
Mon Oct 24 18:42:49 BRST 2016


Rodrigo Souto pushed to branch stable-1.6 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
- - - - -
b76cf339 by Rodrigo Souto at 2016-10-24T20:41:35+00:00
Merge branch 'cherry-pick-3757c1d9' into 'stable-1.6'

Merge branch 'chat-notification' into 'master'

chat: avoid notification crash on browsers that does not support it

See merge request !1031

See merge request !1034
- - - - -


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/compare/0623a26482a67e26e0984462a4b3cef3f0d039c0...b76cf339b48888283a1b5cbec6b06da023a524dd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20161024/da9614c7/attachment-0001.html>


More information about the Noosfero-dev mailing list