Index: lib/notificationHelper.js |
=================================================================== |
--- a/lib/notificationHelper.js |
+++ b/lib/notificationHelper.js |
@@ -206,14 +206,21 @@ |
// from closing automatically. |
priority: 2 |
}; |
- browser.notifications.create("", notificationOptions, () => |
+ |
+ // Firefox and Opera don't support buttons. Firefox throws synchronously, |
+ // while Opera gives an asynchronous error. Wrapping the promise like |
+ // this, turns the synchronous error on Firefox into a promise rejection. |
+ new Promise(resolve => |
{ |
- // Opera does not support the addition of buttons to notifications. |
- // Question type notfications always include buttons. |
- if (browser.runtime.lastError && activeNotification.type != "question") |
+ resolve(browser.notifications.create(notificationOptions)); |
+ }).catch(() => |
+ { |
+ // Without buttons, showing notifications of the type "question" is |
+ // pointless. For other notifications, retry with the buttons removed. |
+ if (activeNotification.type != "question") |
{ |
delete notificationOptions.buttons; |
- browser.notifications.create("", notificationOptions); |
+ browser.notifications.create(notificationOptions); |
} |
}); |
} |