diff --git a/src/converse-core.js b/src/converse-core.js index b8d033b8d..dac9392ec 100755 --- a/src/converse-core.js +++ b/src/converse-core.js @@ -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) { diff --git a/src/converse-notification.js b/src/converse-notification.js index bddd18e51..5e6bccfa3 100644 --- a/src/converse-notification.js +++ b/src/converse-notification.js @@ -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); } }); }));