diff --git a/client/src/components/User/UserPreferences.vue b/client/src/components/User/UserPreferences.vue index 6066a5bf348..c3a5e7b2a6a 100644 --- a/client/src/components/User/UserPreferences.vue +++ b/client/src/components/User/UserPreferences.vue @@ -177,16 +177,20 @@ export default { }, methods: { toggleNotifications() { - Notification.requestPermission().then(function (permission) { - //If the user accepts, let's create a notification - if (permission === "granted") { - new Notification("Notifications enabled", { - icon: "static/favicon.ico", - }); - } else { - alert("Notifications disabled, please re-enable through browser settings."); - } - }); + if (window.Notification) { + Notification.requestPermission().then(function (permission) { + //If the user accepts, let's create a notification + if (permission === "granted") { + new Notification("Notifications enabled", { + icon: "static/favicon.ico", + }); + } else { + alert("Notifications disabled, please re-enable through browser settings."); + } + }); + } else { + alert("Notifications are not supported by this browser."); + } }, openManageCustomBuilds() { const Galaxy = getGalaxyInstance(); diff --git a/client/src/mvc/dataset/dataset-model.js b/client/src/mvc/dataset/dataset-model.js index bc69f77b972..d968c3c7585 100644 --- a/client/src/mvc/dataset/dataset-model.js +++ b/client/src/mvc/dataset/dataset-model.js @@ -103,19 +103,25 @@ var DatasetAssociation = Backbone.Model.extend(BASE_MVC.LoggableMixin).extend( this.trigger("state:ready", currModel, newState, this.previous("state")); if (newState != "discarded") { if (newState === "ok") { - new Notification(`Job complete: ${this.get("name")}`, { - icon: "static/favicon.ico", - }); + // If Notifications are supported, send one. + if (window.Notification) { + new Notification(`Job complete: ${this.get("name")}`, { + icon: "static/favicon.ico", + }); + } if (TAB_UPDATES.is_hidden()) { TAB_UPDATES.hidden_count(hiddenupdates); hiddenupdates++; } } else if (newState == "error") { - new Notification(`Job failure: ${this.get("name")}`, { - icon: "static/erricon.ico", - }); - if (TAB_UPDATES.is_hidden() && Notification.permission == "granted") { - TAB_UPDATES.change_favicon("static/erricon.ico"); + // If Notifications are supported, send one. + if (window.Notification) { + new Notification(`Job failure: ${this.get("name")}`, { + icon: "static/erricon.ico", + }); + if (TAB_UPDATES.is_hidden() && Notification.permission == "granted") { + TAB_UPDATES.change_favicon("static/erricon.ico"); + } } } }