Initialization updated
This commit is contained in:
parent
48617443d7
commit
d7e0af1af6
|
@ -70,7 +70,6 @@ const Setting = {
|
||||||
'STRIP_METADATA': 'stripMetadata',
|
'STRIP_METADATA': 'stripMetadata',
|
||||||
'LAST_MAPPING_UPDATE': 'lastMappingUpdate',
|
'LAST_MAPPING_UPDATE': 'lastMappingUpdate',
|
||||||
'ALLOWLISTED_DOMAINS': 'allowlistedDomains',
|
'ALLOWLISTED_DOMAINS': 'allowlistedDomains',
|
||||||
'WHITELISTED_DOMAINS': 'whitelistedDomains',
|
|
||||||
'XHR_TEST_DOMAIN': 'xhrTestDomain',
|
'XHR_TEST_DOMAIN': 'xhrTestDomain',
|
||||||
'LOGGING': 'enableLogging',
|
'LOGGING': 'enableLogging',
|
||||||
'DOMAINS_MANIPULATE_DOM': 'domainsManipulateDOM',
|
'DOMAINS_MANIPULATE_DOM': 'domainsManipulateDOM',
|
||||||
|
@ -104,7 +103,6 @@ const SettingDefaults = {
|
||||||
[Setting.STORAGE_TYPE]: 'local',
|
[Setting.STORAGE_TYPE]: 'local',
|
||||||
[Setting.STRIP_METADATA]: true,
|
[Setting.STRIP_METADATA]: true,
|
||||||
[Setting.ALLOWLISTED_DOMAINS]: {},
|
[Setting.ALLOWLISTED_DOMAINS]: {},
|
||||||
[Setting.WHITELISTED_DOMAINS]: {},
|
|
||||||
[Setting.XHR_TEST_DOMAIN]: Address.LOCALCDN,
|
[Setting.XHR_TEST_DOMAIN]: Address.LOCALCDN,
|
||||||
[Setting.BADGE_COLOR]: '#4A826C',
|
[Setting.BADGE_COLOR]: '#4A826C',
|
||||||
[Setting.BADGE_TEXT_COLOR]: '#FFFFFF'
|
[Setting.BADGE_TEXT_COLOR]: '#FFFFFF'
|
||||||
|
|
44
core/main.js
44
core/main.js
|
@ -32,8 +32,31 @@ main._initializeSettings = function () {
|
||||||
storageManager.checkStorageType();
|
storageManager.checkStorageType();
|
||||||
|
|
||||||
storageManager.type.get(null, function (items) {
|
storageManager.type.get(null, function (items) {
|
||||||
if (items === null) {
|
// Delete old keys
|
||||||
items = SettingDefaults; // Restore setting defaults.
|
if (typeof items.whitelistedDomains !== 'undefined') {
|
||||||
|
if (Object.keys(items.allowlistedDomains).length === 0) {
|
||||||
|
items.allowlistedDomains = items.whitelistedDomains;
|
||||||
|
}
|
||||||
|
delete items['whitelistedDomains'];
|
||||||
|
storageManager.type.remove('whitelistedDomains');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert value of notifications
|
||||||
|
if (typeof items.hideReleaseNotes !== 'undefined') {
|
||||||
|
if (items.hideReleaseNotes === true) {
|
||||||
|
items.updateNotification = 0;
|
||||||
|
} else {
|
||||||
|
items.updateNotification = 2;
|
||||||
|
}
|
||||||
|
delete items['hideReleaseNotes'];
|
||||||
|
storageManager.type.remove('hideReleaseNotes');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use default if key is missing
|
||||||
|
for (const key of Object.keys(SettingDefaults)) {
|
||||||
|
if (items[key] === undefined) {
|
||||||
|
items[key] = SettingDefaults[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (items.disablePrefetch !== false) {
|
if (items.disablePrefetch !== false) {
|
||||||
|
@ -42,23 +65,6 @@ main._initializeSettings = function () {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy old data
|
|
||||||
if (Object.keys(items.allowlistedDomains).length === 0) {
|
|
||||||
items.allowlistedDomains = items.whitelistedDomains;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete old key
|
|
||||||
if (typeof items.whitelistedDomains !== 'undefined') {
|
|
||||||
delete items['whitelistedDomains'];
|
|
||||||
storageManager.type.remove('whitelistedDomains');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert value of notifications
|
|
||||||
if (typeof items.hideReleaseNotes !== 'undefined') {
|
|
||||||
items.updateNotification = items.hideReleaseNotes ? 0 : 2;
|
|
||||||
delete items['hideReleaseNotes'];
|
|
||||||
storageManager.type.remove('hideReleaseNotes');
|
|
||||||
}
|
|
||||||
|
|
||||||
stateManager.selectedIcon = items.selectedIcon;
|
stateManager.selectedIcon = items.selectedIcon;
|
||||||
wrappers.setIcon({
|
wrappers.setIcon({
|
||||||
|
|
Loading…
Reference in New Issue