Commit c793b846 authored by JC Brand's avatar JC Brand

Only ask for permission once the user is already logged in

updates #443
parent 02faa555
......@@ -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) {
......
......@@ -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);
}
});
}));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment