Require browser notification permissions only when the user signs in

The only notification right now is for signed in users that are viewing
their room's page, so request permission only in this case.
This commit is contained in:
Leonardo Crauss Daronco 2016-12-09 15:18:41 -02:00
parent bf7d087f45
commit 87bccb1204
1 changed files with 7 additions and 2 deletions

View File

@ -68,5 +68,10 @@ var showNotification = function(title, options) {
}
};
// TODO: only need permissions if the user is signed in
Notification.requestPermission();
// For now there are notifications only for users signed in and when they
// are in their room's page
$(document).on("turbolinks:load", function() {
if (GreenLight.user.roomOwner) {
Notification.requestPermission();
}
});