Only ask for permission once the user is already logged in

updates #443
This commit is contained in:
JC Brand 2016-03-08 22:36:13 +00:00
parent 02faa555bb
commit c793b846fb
2 changed files with 11 additions and 4 deletions

View File

@ -629,6 +629,7 @@
if (converse.disconnection_cause === Strophe.Status.CONNFAIL && converse.auto_reconnect) {
converse.reconnect(condition);
} else {
// FIXME: leaky abstraction from converse-controlbox.js
converse.renderLoginPanel();
}
} else if (status === Strophe.Status.ERROR) {
@ -646,6 +647,7 @@
} else if (status === Strophe.Status.DISCONNECTING) {
// FIXME: what about prebind?
if (!converse.connection.connected) {
// FIXME: leaky abstraction from converse-controlbox.js
converse.renderLoginPanel();
}
if (condition) {

View File

@ -20,10 +20,6 @@
var supports_html5_notification = "Notification" in window;
if (supports_html5_notification && Notification.permission !== 'denied') {
// Ask user to enable HTML5 notifications
Notification.requestPermission();
}
converse_api.plugins.add('notification', {
@ -195,9 +191,18 @@
}
};
converse.requestPermission = function (evt) {
if (supports_html5_notification &&
! _.contains(['denied', 'granted'], Notification.permission)) {
// Ask user to enable HTML5 notifications
Notification.requestPermission();
}
};
converse.on('contactRequest', converse.handleContactRequestNotification);
converse.on('contactStatusChanged', converse.handleChatStateNotification);
converse.on('message', converse.handleMessageNotification);
converse.on('ready', converse.requestPermission);
}
});
}));