Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: adblockplus/Api.jsm

Issue 4826014056185856: Add filtersLoaded and filterLoadListener to AdblockPlusApi (Closed)
Patch Set: Created March 20, 2015, 4:26 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: adblockplus/Api.jsm
===================================================================
--- a/adblockplus/Api.jsm
+++ b/adblockplus/Api.jsm
@@ -32,12 +32,20 @@
return result.exports;
}
+let {FilterNotifier} = require("filterNotifier");
let {FilterStorage} = require("filterStorage");
let {Prefs} = require("prefs");
let {UI} = require("ui");
+let filtersLoaded = false;
+
var AdblockPlusApi =
{
+ get filtersLoaded()
+ {
+ return filtersLoaded;
Wladimir Palant 2015/03/20 16:38:20 return FilterStorage._loading?
Felix Dahlke 2015/03/20 16:54:57 What we want to know here is whether the filters h
Felix Dahlke 2015/03/20 21:13:02 Well actually, you're right. Api.jsm is not necess
+ },
+ filterLoadListener: null,
get acceptableAdsEnabled()
{
return FilterStorage.subscriptions.some(
@@ -49,3 +57,14 @@
UI.toggleAcceptableAds();
}
};
+
+FilterNotifier.addListener(function(action)
+{
+ if (action != "load")
+ return;
+
+ filtersLoaded = true;
Wladimir Palant 2015/03/20 16:38:20 This listener should be removed after the first ca
Felix Dahlke 2015/03/20 16:54:57 Done.
Felix Dahlke 2015/03/20 17:13:06 Well, NOW it's done. Misunderstood you, unregister
+ if ("filterLoadListener" in AdblockPlusApi &&
+ typeof AdblockPlusApi.filterLoadListener == "function")
Wladimir Palant 2015/03/20 16:38:20 Using typeof is sufficient, "filterLoadListener" i
Felix Dahlke 2015/03/20 16:54:57 Ouch, getting rusty...
+ AdblockPlusApi.filterLoadListener();
+});
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld