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
async function uninstall(aData, aReason) {
if (aReason === ADDON_UNINSTALL
|| aReason === ADDON_DISABLE) {
async function uninstall({resourceURI}, aReason) {
if (checkLegacyFirefox()) {
if (aReason === ADDON_UNINSTALL) {
unloadStyles(resourceURI);
await removeChanges();
}
}
}
async function removeChanges() {
const config = await getConfig();
const storedPrefs = config.savedConfiguration.prefs || {};
PREFS.forEach((pref) => {
@ -146,25 +153,35 @@ async function uninstall(aData, aReason) {
Services.prefs.setBoolPref(pref.name, value);
}
});
}
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
function startup({webExtension, resourceURI}) {
const version = Services.appinfo.version;
const versionMatch = version.match(/^([0-9]+)\./)[1];
if (versionMatch === "55"
|| versionMatch === "56") {
if (checkLegacyFirefox()) {
loadStyles(resourceURI);
}
// Reset prefs that may have changed, or are legacy
install();
}
// Start the embedded webextension.
webExtension.startup();
}
// eslint-disable-next-line no-unused-vars
function shutdown({resourceURI}) {
function shutdown({resourceURI}, aReason) {
if (checkLegacyFirefox()) {
unloadStyles(resourceURI);
if (aReason === ADDON_DISABLE) {
removeChanges();
}
}
}