noosfero | Chat error when notifications as blocked (#263)

Rodrigo Souto gitlab at mg.gitlab.com
Wed May 31 11:53:16 BRT 2017


New Issue was created.

Issue 263: https://gitlab.com/noosfero/noosfero/issues/263
Author:    Rodrigo Souto
Assignee:  

When the user block notification for Noosfero the chat show the following behavior:
1. The user receives the first message without problems.
2. The second message throws an js error.
3. The user does not receive anymore message until page reload.

Here is the error that is thrown:
```
function C.on_private_message()  - error -  TypeError: i is null
Stack trace:
notifyMe at http://ola.coop.br/assets/application-a9f970d6dc929458260eb2a17c407813.js:1:16260
w at http://ola.coop.br/assets/chat-d1694930e8b262c1d739411f02e4e995.js:1:4425
C.on_private_message at http://ola.coop.br/assets/chat-d1694930e8b262c1d739411f02e4e995.js:1:13797
r.Handler.prototype.run at http://ola.coop.br/assets/vendor/strophejs-1.1.3/strophe.min-f6ef4617019540346b7891378afb6eca.js:1:15799
r.Connection.prototype._dataRecv/<@http://ola.coop.br/assets/vendor/strophejs-1.1.3/strophe.min-f6ef4617019540346b7891378afb6eca.js:1:22361
r.forEachChild at http://ola.coop.br/assets/vendor/strophejs-1.1.3/strophe.min-f6ef4617019540346b7891378afb6eca.js:1:8457
r.Connection.prototype._dataRecv at http://ola.coop.br/assets/vendor/strophejs-1.1.3/strophe.min-f6ef4617019540346b7891378afb6eca.js:1:22194
Strophe.Bosh.prototype._onRequestStateChange at http://ola.coop.br/assets/vendor/strophejs-1.1.3/strophe.min-f6ef4617019540346b7891378afb6eca.js:2:5883
 i is null
```

After some investigation, I could narrow the problem to this point in the code:
```
# public/javascripts/application.js

  else if (Notification.permission !== 'denied') {
    Notification.requestPermission(function (permission) {
      // Whatever the user answers, we make sure we store the information
      if (!('permission' in Notification)) {
        Notification.permission = permission;
      }

      // If the user is okay, let's create a notification
      if (permission === "granted") {
        notification = new Notification(title, options);
      }
    });
  }

  notification.onclick = function(){
    notification.close();
    // Chromium tweak
    window.open().close();
    window.focus();
  };
```

Apparently, the notification is not created since the permission is blocked but the method `notification.onclick` is called without any check.

---
Reply to this email directly or view it on GitLab: https://gitlab.com/noosfero/noosfero/issues/263
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170531/36ff942f/attachment.html>


More information about the Noosfero-dev mailing list