mirror of https://github.com/gorhill/uBlock.git
Throw when useLists() called concurrently
Related feedback: - https://github.com/gorhill/uBlock/pull/3836/files#r690687656
This commit is contained in:
parent
60e254608a
commit
7a5c4e9547
|
@ -146,6 +146,10 @@ function compileList({ name, raw }, compiler, writer, options = {}) {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
async function useLists(lists, options = {}) {
|
async function useLists(lists, options = {}) {
|
||||||
|
if ( useLists.promise !== null ) {
|
||||||
|
throw new Error('Pending useLists() operation');
|
||||||
|
}
|
||||||
|
|
||||||
// Remove all filters
|
// Remove all filters
|
||||||
snfe.reset();
|
snfe.reset();
|
||||||
|
|
||||||
|
@ -174,13 +178,17 @@ async function useLists(lists, options = {}) {
|
||||||
promises.push(promise.then(list => consumeList(list)));
|
promises.push(promise.then(list => consumeList(list)));
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.all(promises);
|
useLists.promise = Promise.all(promises);
|
||||||
|
await useLists.promise;
|
||||||
|
useLists.promise = null;
|
||||||
|
|
||||||
// Commit changes
|
// Commit changes
|
||||||
snfe.freeze();
|
snfe.freeze();
|
||||||
snfe.optimize();
|
snfe.optimize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
useLists.promise = null;
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
class MockStorage {
|
class MockStorage {
|
||||||
|
|
Loading…
Reference in New Issue