Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rpl/285c068c7cb220d91c5ee54b2a9f8178 to your computer and use it in GitHub Desktop.
Save rpl/285c068c7cb220d91c5ee54b2a9f8178 to your computer and use it in GitHub Desktop.
exception on ext-notifications.js
diff --git a/toolkit/components/extensions/ext-notifications.js b/toolkit/components/extensions/ext-notifications.js
--- a/toolkit/components/extensions/ext-notifications.js
+++ b/toolkit/components/extensions/ext-notifications.js
@@ -47,24 +47,31 @@ Notification.prototype = {
svc.closeAlert(this.id);
} catch (e) {
// This will fail if the OS doesn't support this function.
}
notificationsMap.get(this.extension).delete(this.id);
},
observe(subject, topic, data) {
+ let notifications = notificationsMap.get(this.extension);
+ if (!notifications) {
+ // no notifications found for the addon, e.g. the addon has been
+ // already unloaded.
+ return;
+ }
+
if (topic === "alertclickcallback") {
- notificationsMap.get(this.extension).emit("clicked", data);
+ notifications.emit("clicked", data);
}
if (topic === "alertfinished") {
- notificationsMap.get(this.extension).emit("closed", data);
+ notifications.emit("closed", data);
}
- notificationsMap.get(this.extension).delete(this.id);
+ notifications.delete(this.id);
},
};
/* eslint-disable mozilla/balanced-listeners */
extensions.on("startup", (type, extension) => {
let map = new Map();
EventEmitter.decorate(map);
notificationsMap.set(extension, map);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment