diff options
author | Alessio Vanni <vannilla@firemail.cc> | 2019-06-22 00:17:30 +0200 |
---|---|---|
committer | Alessio Vanni <vannilla@firemail.cc> | 2019-06-22 00:17:30 +0200 |
commit | d5f07761dcaad4128a222537fc36d49e1debb55b (patch) | |
tree | b78fe518629d9a312274fd3a52717dc36010d797 /js/vapi-background.js | |
parent | fc2df27d5768294f22a4d9ad049d45f2d0d52781 (diff) | |
download | ematrix-d5f07761dcaad4128a222537fc36d49e1debb55b.tar.lz ematrix-d5f07761dcaad4128a222537fc36d49e1debb55b.tar.xz ematrix-d5f07761dcaad4128a222537fc36d49e1debb55b.zip |
More refactoring
Diffstat (limited to 'js/vapi-background.js')
-rw-r--r-- | js/vapi-background.js | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/js/vapi-background.js b/js/vapi-background.js index fbb7353..a482af6 100644 --- a/js/vapi-background.js +++ b/js/vapi-background.js @@ -60,7 +60,7 @@ // List of things that needs to be destroyed when disabling the extension // Only functions should be added to it - + // eMatrix: taken care by vAPI.addCleanUpTask --- use that function let cleanupTasks = []; // This must be updated manually, every time a new task is added/removed @@ -301,7 +301,8 @@ }, }; - cleanupTasks.push(vAPI.browserSettings.restoreAll.bind(vAPI.browserSettings)); + vAPI.addCleanUpTask(vAPI.browserSettings + .restoreAll.bind(vAPI.browserSettings)); // API matches that of chrome.storage.local: // https://developer.chrome.com/extensions/storage @@ -363,7 +364,7 @@ } // Database was opened, register cleanup task - cleanupTasks.push(close); + vAPI.addCleanUpTask(close); // Setup database db.createAsyncStatement('CREATE TABLE IF NOT EXISTS ' @@ -752,7 +753,7 @@ Services.ww.registerNotification(listeners); })(); - cleanupTasks.push(function() { + vAPI.addCleanUpTask(function() { Services.wm.removeListener(listeners); Services.ww.unregisterNotification(listeners); windowToIdMap.clear(); @@ -908,7 +909,7 @@ this.onMessage); this.globalMessageManager.loadFrameScript(this.frameScript, true); - cleanupTasks.push(function () { + vAPI.addCleanUpTask(function () { let gmm = vAPI.messaging.globalMessageManager; gmm.removeDelayedFrameScript(vAPI.messaging.frameScript); @@ -1560,7 +1561,7 @@ httpObserver.register(); - cleanupTasks.push(function () { + vAPI.addCleanUpTask(function () { if (!vAPI.modernFirefox) { vAPI.messaging.globalMessageManager .removeMessageListener(shouldLoadListenerMessageName, @@ -1979,7 +1980,7 @@ .addMessageListener(location.host + ':closePopup', onPopupCloseRequested); - cleanupTasks.push(shutdown); + vAPI.addCleanUpTask(shutdown); }; })(); @@ -2304,7 +2305,7 @@ CustomizableUI.createWidget(this); - cleanupTasks.push(shutdown); + vAPI.addCleanUpTask(shutdown); }; })(); @@ -2315,7 +2316,7 @@ // button code is one single cleanup task regardless of platform. // eMatrix: might not be needed anymore if (vAPI.toolbarButton.init === null) { - cleanupTasks.push(function(){}); + vAPI.addCleanUpTask(function(){}); } })(); @@ -2586,7 +2587,7 @@ Services.obs.addObserver(observer, 'addon-options-displayed', false); - cleanupTasks.push(unregister); + vAPI.addCleanUpTask(unregister); vAPI.deferUntil(canInit, init, { next: 463 }); }; @@ -2801,7 +2802,7 @@ vAPI.cookies.start = function () { Services.obs.addObserver(this, 'cookie-changed', false); Services.obs.addObserver(this, 'private-cookie-changed', false); - cleanupTasks.push(this.stop.bind(this)); + vAPI.addCleanUpTask(this.stop.bind(this)); }; vAPI.cookies.stop = function () { |