Skip to content

Commit 3a7993c

Browse files
committed
Explicitly pass store to RuleSets.initialize.
1 parent e0eb11f commit 3a7993c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

chromium/background.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ let all_rules = new rules.RuleSets();
77
async function initialize() {
88
await store.initialize();
99
await initializeStoredGlobals();
10-
await all_rules.initialize();
10+
await all_rules.initialize(store);
1111

1212
// Send a message to the embedded webextension bootstrap.js to get settings to import
1313
chrome.runtime.sendMessage("import-legacy-data", import_settings);
@@ -597,7 +597,7 @@ async function import_settings(settings) {
597597
});
598598

599599
Object.assign(all_rules, new rules.RuleSets());
600-
await all_rules.initialize();
600+
await all_rules.initialize(store);
601601

602602
}
603603
}

chromium/rules.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,8 @@ function RuleSets() {
206206

207207
RuleSets.prototype = {
208208

209-
initialize: async function() {
209+
initialize: async function(store) {
210+
this.store = store;
210211
this.ruleActiveStates = store.localStorage;
211212
this.addFromJson(util.loadExtensionFile('rules/default.rulesets', 'json'));
212213
this.loadStoredUserRules();
@@ -356,7 +357,7 @@ RuleSets.prototype = {
356357
* Retrieve stored user rules from localStorage
357358
**/
358359
getStoredUserRules: function() {
359-
const oldUserRuleString = store.localStorage.getItem(this.USER_RULE_KEY);
360+
const oldUserRuleString = this.store.localStorage.getItem(this.USER_RULE_KEY);
360361
let oldUserRules = [];
361362
if (oldUserRuleString) {
362363
oldUserRules = JSON.parse(oldUserRuleString);
@@ -390,7 +391,7 @@ RuleSets.prototype = {
390391
// client windows in different event loops.
391392
oldUserRules.push(params);
392393
// TODO: can we exceed the max size for storage?
393-
store.localStorage.setItem(this.USER_RULE_KEY, JSON.stringify(oldUserRules));
394+
this.store.localStorage.setItem(this.USER_RULE_KEY, JSON.stringify(oldUserRules));
394395
}
395396
},
396397

@@ -406,13 +407,13 @@ RuleSets.prototype = {
406407
!(r.host == ruleset.name &&
407408
r.redirectTo == ruleset.rules[0].to)
408409
);
409-
store.localStorage.setItem(this.USER_RULE_KEY, JSON.stringify(userRules));
410+
this.store.localStorage.setItem(this.USER_RULE_KEY, JSON.stringify(userRules));
410411
}
411412
},
412413

413414
addStoredCustomRulesets: function(){
414415
return new Promise(resolve => {
415-
store.get({
416+
this.store.get({
416417
legacy_custom_rulesets: [],
417418
debugging_rulesets: ""
418419
}, item => {

0 commit comments

Comments
 (0)