mirror of https://github.com/gorhill/uBlock.git
Be prepared to deal with failure to read user settings
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/507
This commit is contained in:
parent
48ac4b21c6
commit
1a7a3298e2
|
@ -296,6 +296,13 @@ const onSystemSettingsReady = function(fetched) {
|
||||||
const onFirstFetchReady = function(fetched) {
|
const onFirstFetchReady = function(fetched) {
|
||||||
log.info(`First fetch ready ${Date.now()-vAPI.T0} ms after launch`);
|
log.info(`First fetch ready ${Date.now()-vAPI.T0} ms after launch`);
|
||||||
|
|
||||||
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/507
|
||||||
|
// Firefox-specific: somehow `fetched` is undefined under certain
|
||||||
|
// circumstances even though we asked to load with default values.
|
||||||
|
if ( fetched instanceof Object === false ) {
|
||||||
|
fetched = createDefaultProps();
|
||||||
|
}
|
||||||
|
|
||||||
// https://github.com/gorhill/uBlock/issues/747
|
// https://github.com/gorhill/uBlock/issues/747
|
||||||
µb.firstInstall = fetched.version === '0.0.0.0';
|
µb.firstInstall = fetched.version === '0.0.0.0';
|
||||||
|
|
||||||
|
@ -331,11 +338,7 @@ const fromFetch = function(to, fetched) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
const createDefaultProps = function() {
|
||||||
|
|
||||||
const onSelectedFilterListsReady = function() {
|
|
||||||
log.info(`List selection ready ${Date.now()-vAPI.T0} ms after launch`);
|
|
||||||
|
|
||||||
const fetchableProps = {
|
const fetchableProps = {
|
||||||
'commandShortcuts': [],
|
'commandShortcuts': [],
|
||||||
'compiledMagic': 0,
|
'compiledMagic': 0,
|
||||||
|
@ -361,12 +364,10 @@ const onSelectedFilterListsReady = function() {
|
||||||
'selfieMagic': 0,
|
'selfieMagic': 0,
|
||||||
'version': '0.0.0.0'
|
'version': '0.0.0.0'
|
||||||
};
|
};
|
||||||
|
|
||||||
toFetch(µb.localSettings, fetchableProps);
|
toFetch(µb.localSettings, fetchableProps);
|
||||||
toFetch(µb.userSettings, fetchableProps);
|
toFetch(µb.userSettings, fetchableProps);
|
||||||
toFetch(µb.restoreBackupSettings, fetchableProps);
|
toFetch(µb.restoreBackupSettings, fetchableProps);
|
||||||
|
return fetchableProps;
|
||||||
vAPI.storage.get(fetchableProps, onFirstFetchReady);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
@ -395,9 +396,10 @@ const onAdminSettingsRestored = function() {
|
||||||
onHiddenSettingsReady()
|
onHiddenSettingsReady()
|
||||||
),
|
),
|
||||||
µb.loadSelectedFilterLists(),
|
µb.loadSelectedFilterLists(),
|
||||||
]).then(( ) =>
|
]).then(( ) => {
|
||||||
onSelectedFilterListsReady()
|
log.info(`List selection ready ${Date.now()-vAPI.T0} ms after launch`);
|
||||||
);
|
vAPI.storage.get(createDefaultProps(), onFirstFetchReady);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue