Change (un)install changes to only work for >57. Fixes #858 and Fixes #900

This commit is contained in:
Jonathan Kingston 2017-10-09 14:51:10 +01:00
parent 92560e1172
commit e85d37ff7c
6 changed files with 41 additions and 24 deletions

35
bootstrap.js vendored
View file

@ -130,9 +130,16 @@ async function install() {
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
async function uninstall(aData, aReason) { async function uninstall({resourceURI}, aReason) {
if (aReason === ADDON_UNINSTALL if (checkLegacyFirefox()) {
|| aReason === ADDON_DISABLE) { if (aReason === ADDON_UNINSTALL) {
unloadStyles(resourceURI);
await removeChanges();
}
}
}
async function removeChanges() {
const config = await getConfig(); const config = await getConfig();
const storedPrefs = config.savedConfiguration.prefs || {}; const storedPrefs = config.savedConfiguration.prefs || {};
PREFS.forEach((pref) => { PREFS.forEach((pref) => {
@ -147,24 +154,34 @@ async function uninstall(aData, aReason) {
} }
}); });
} }
function checkLegacyFirefox() {
const version = Services.appinfo.version;
const versionMatch = version.match(/^([0-9]+)\./)[1];
if (Number(versionMatch) <= 56) {
return true;
}
return false;
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function startup({webExtension, resourceURI}) { function startup({webExtension, resourceURI}) {
const version = Services.appinfo.version; if (checkLegacyFirefox()) {
const versionMatch = version.match(/^([0-9]+)\./)[1];
if (versionMatch === "55"
|| versionMatch === "56") {
loadStyles(resourceURI); loadStyles(resourceURI);
}
// Reset prefs that may have changed, or are legacy // Reset prefs that may have changed, or are legacy
install(); install();
}
// Start the embedded webextension. // Start the embedded webextension.
webExtension.startup(); webExtension.startup();
} }
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
function shutdown({resourceURI}) { function shutdown({resourceURI}, aReason) {
if (checkLegacyFirefox()) {
unloadStyles(resourceURI); unloadStyles(resourceURI);
if (aReason === ADDON_DISABLE) {
removeChanges();
}
}
} }