Index: lib/ui.js |
=================================================================== |
--- a/lib/ui.js |
+++ b/lib/ui.js |
@@ -393,31 +393,35 @@ let UI = exports.UI = |
* can be added to the UI. |
*/ |
initDone: function() |
{ |
// The icon might be added already, make sure its state is correct |
this.updateState(); |
// Listen for pref and filters changes |
- Prefs.addListener(function(name) |
+ Prefs.addListener(name => |
{ |
if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaultstatusbaraction") |
this.updateState(); |
else if (name == "showinstatusbar") |
{ |
for (let window of this.applicationWindows) |
this.updateStatusbarIcon(window); |
} |
- }.bind(this)); |
- FilterNotifier.addListener(function(action) |
+ }); |
+ |
+ for (let eventName of [ |
+ "filter.added", "filter.removed", "filter.disabled", |
+ "subscription.added", "subscription.removed", "subscription.disabled", |
+ "subscription.updated", "load" |
+ ]) |
{ |
- if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(action) || action == "load") |
- this.updateState(); |
- }.bind(this)); |
+ FilterNotifier.on(eventName, () => this.updateState()); |
+ } |
Notification.addShowListener(notification => |
{ |
let window = this.currentWindow; |
if (!window) |
return; |
let button = window.document.getElementById("abp-toolbarbutton") |