[Git][noosfero/noosfero][master] 2 commits: chat: avoid notification crash on browsers that does not support it
Rodrigo Souto
gitlab at mg.gitlab.com
Mon Oct 24 15:20:53 BRST 2016
Rodrigo Souto pushed to branch master at Noosfero / noosfero
Commits:
74269364 by Rodrigo Souto at 2016-09-19T13:26:00-03:00
chat: avoid notification crash on browsers that does not support it
- - - - -
3757c1d9 by Rodrigo Souto at 2016-10-24T17:20:45+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/compare/63f4b816be4c6e228570014ef0817a17ce8d3b99...3757c1d92b3a13a057cb4fb82ee24d616da18964
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20161024/e775b739/attachment-0001.html>
More information about the Noosfero-dev
mailing list