proxifiedContainers.delete routine added and loosely tested

This commit is contained in:
Samuel Crypto 2018-11-01 10:57:42 -04:00
parent fc2c7ff4be
commit 8ee45a38f0

View file

@ -146,5 +146,31 @@ proxifiedContainers = {
return result; return result;
} }
},
//Deletes the proxy information object for a specified cookieStoreId [useful for cleaning]
delete(cookieStoreId) {
return new Promise((resolve, reject) => {
// Assumes proxy is a properly formatted object
proxifiedContainers.retrieve().then((proxifiedContainersStore) => {
let index = proxifiedContainersStore.findIndex(i => i.cookieStoreId === cookieStoreId);
if (index === -1) {
reject({error: "not-found", message: `Container '${cookieStoreId}' not found.`});
} else {
delete proxifiedContainersStore[index];
}
browser.storage.local.set({
proxifiedContainersKey: proxifiedContainersStore
});
resolve();
}, (errorObj) => {
reject(errorObj);
}).catch((error) => {
throw error;
});
});
} }
}; };