Fix migrations
This commit is contained in:
parent
ea4fb95a3c
commit
f916cffd41
@ -13,6 +13,7 @@ import EmbeddedContentSettingsOverridePolicy from '../../common/enums/EmbeddedCo
|
|||||||
import LegacyExtensionMode from '../../common/enums/LegacyExtensionMode.enum';
|
import LegacyExtensionMode from '../../common/enums/LegacyExtensionMode.enum';
|
||||||
import ExtensionMode from '../../common/enums/ExtensionMode.enum';
|
import ExtensionMode from '../../common/enums/ExtensionMode.enum';
|
||||||
import { PlayerDetectionMode } from '../../common/enums/PlayerDetectionMode.enum';
|
import { PlayerDetectionMode } from '../../common/enums/PlayerDetectionMode.enum';
|
||||||
|
import { SiteSupportLevel } from '../../common/enums/SiteSupportLevel.enum';
|
||||||
|
|
||||||
|
|
||||||
const ExtensionConfPatch = Object.freeze([
|
const ExtensionConfPatch = Object.freeze([
|
||||||
@ -306,7 +307,7 @@ const ExtensionConfPatch = Object.freeze([
|
|||||||
userOptions.sites[key].enableKeyboard = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
|
userOptions.sites[key].enableKeyboard = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
|
||||||
userOptions.sites[key].enableUI = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
|
userOptions.sites[key].enableUI = convertLegacyExtensionMode(userOptions.sites[key].enable as any);
|
||||||
|
|
||||||
logger.log('migrated site', key, userOptions.sites[key]);
|
logger.log('updateFn', 'migrated site', key, userOptions.sites[key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -321,15 +322,26 @@ const ExtensionConfPatch = Object.freeze([
|
|||||||
forVersion: '6.3.996',
|
forVersion: '6.3.996',
|
||||||
updateFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface, logger?) => {
|
updateFn: (userOptions: SettingsInterface, defaultOptions: SettingsInterface, logger?) => {
|
||||||
for (const site in userOptions.sites) {
|
for (const site in userOptions.sites) {
|
||||||
for (const domConf in userOptions.sites.DOMConfig) {
|
const siteData = userOptions.sites[site];
|
||||||
|
logger.log('updateFn', 'migrating settings for', site, ' — persistCSA?', siteData.persistCSA, 'typeof persistCSA?', typeof siteData.persistCSA, 'does domconfig exist?', siteData.DOMConfig);
|
||||||
|
|
||||||
|
if (typeof siteData.persistCSA !== 'number') {
|
||||||
|
userOptions.sites[site].persistCSA = CropModePersistence.Default;
|
||||||
|
} else {
|
||||||
|
userOptions.sites[site].persistCSA = userOptions.sites[site].persistCSA ?? CropModePersistence.Default;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const domConf in siteData.DOMConfig) {
|
||||||
|
logger.log('updateFn', "Updating domconf", domConf);
|
||||||
const oldConf = userOptions.sites[site].DOMConfig[domConf] as any;
|
const oldConf = userOptions.sites[site].DOMConfig[domConf] as any;
|
||||||
|
logger.log('updateFn', "——— oldConf:", oldConf);
|
||||||
|
|
||||||
const newConf: any = {
|
const newConf: any = {
|
||||||
type: oldConf.type ?? userOptions.sites[site].type,
|
type: oldConf.type ?? userOptions.sites[site].type,
|
||||||
elements: {}
|
elements: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (oldConf.elements.player) {
|
if (oldConf.elements?.player) {
|
||||||
newConf.elements['player'] = {
|
newConf.elements['player'] = {
|
||||||
playerDetectionMode: oldConf?.elements?.player?.manual ? (
|
playerDetectionMode: oldConf?.elements?.player?.manual ? (
|
||||||
oldConf?.elements?.player?.querySelectors.trim() ? PlayerDetectionMode.QuerySelectors : PlayerDetectionMode.AncestorIndex
|
oldConf?.elements?.player?.querySelectors.trim() ? PlayerDetectionMode.QuerySelectors : PlayerDetectionMode.AncestorIndex
|
||||||
@ -346,9 +358,9 @@ const ExtensionConfPatch = Object.freeze([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oldConf.elements.video) {
|
if (oldConf.elements?.video) {
|
||||||
newConf.elements['video'] = {
|
newConf.elements['video'] = {
|
||||||
type: oldConf.type ?? userOptions.sites[site].type,
|
type: oldConf.type ?? siteData.type,
|
||||||
elements: {
|
elements: {
|
||||||
video: {
|
video: {
|
||||||
playerDetectionMode: oldConf?.elements?.video?.manual ? PlayerDetectionMode.QuerySelectors : PlayerDetectionMode.Auto,
|
playerDetectionMode: oldConf?.elements?.video?.manual ? PlayerDetectionMode.QuerySelectors : PlayerDetectionMode.Auto,
|
||||||
@ -360,9 +372,49 @@ const ExtensionConfPatch = Object.freeze([
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('new conf:', newConf)
|
||||||
|
|
||||||
userOptions.sites[site].DOMConfig[domConf] = newConf;
|
userOptions.sites[site].DOMConfig[domConf] = newConf;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set new defaults for global and empty:
|
||||||
|
userOptions.sites['@global'].DOMConfig = {
|
||||||
|
'auto': {
|
||||||
|
type: SiteSupportLevel.Unknown,
|
||||||
|
elements: {
|
||||||
|
player: {
|
||||||
|
playerDetectionMode: PlayerDetectionMode.Auto,
|
||||||
|
allowAutoFallback: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
userOptions.sites['@global'].activeDOMConfig = 'auto';
|
||||||
|
userOptions.sites['@empty'].DOMConfig = {
|
||||||
|
'empty': {
|
||||||
|
type: SiteSupportLevel.UserDefined,
|
||||||
|
elements: {
|
||||||
|
player: {
|
||||||
|
playerDetectionMode: PlayerDetectionMode.Auto,
|
||||||
|
allowAutoFallback: true,
|
||||||
|
// ancestorIndex: 1,
|
||||||
|
// querySelectors: '',
|
||||||
|
// customCSS: ''
|
||||||
|
},
|
||||||
|
video: {
|
||||||
|
playerDetectionMode: PlayerDetectionMode.Auto,
|
||||||
|
allowAutoFallback: true,
|
||||||
|
// ancestorIndex: 1,
|
||||||
|
// querySelectors: '',
|
||||||
|
// customCSS: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
userOptions.sites['@empty'].activeDOMConfig = 'empty';
|
||||||
|
|
||||||
|
logger.log('updateFn', 'Migration complete. New site settings:', userOptions.sites);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -823,9 +823,9 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
alignment: {x: VideoAlignmentType.Center, y: VideoAlignmentType.Center},
|
alignment: {x: VideoAlignmentType.Center, y: VideoAlignmentType.Center},
|
||||||
},
|
},
|
||||||
|
|
||||||
activeDOMConfig: 'blank',
|
activeDOMConfig: 'auto',
|
||||||
DOMConfig: {
|
DOMConfig: {
|
||||||
'blank': {
|
'auto': {
|
||||||
type: SiteSupportLevel.Unknown,
|
type: SiteSupportLevel.Unknown,
|
||||||
elements: {
|
elements: {
|
||||||
player: {
|
player: {
|
||||||
@ -839,7 +839,7 @@ const ExtensionConf: SettingsInterface = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@empty": {
|
"@empty": { // New site configs start with this object as template.
|
||||||
defaultType: SiteSupportLevel.Unknown,
|
defaultType: SiteSupportLevel.Unknown,
|
||||||
|
|
||||||
enable: ExtensionMode.Default,
|
enable: ExtensionMode.Default,
|
||||||
|
|||||||
@ -200,6 +200,7 @@ import UploadJsonFileButton from '@components/common/UploadJsonFileButton.vue';
|
|||||||
import { LogAggregator, BLANK_LOGGER_CONFIG } from '@src/ext/lib/logging/LogAggregator';
|
import { LogAggregator, BLANK_LOGGER_CONFIG } from '@src/ext/lib/logging/LogAggregator';
|
||||||
import { SettingsSnapshot } from '@src/ext/lib/settings/SettingsSnapshotManager';
|
import { SettingsSnapshot } from '@src/ext/lib/settings/SettingsSnapshotManager';
|
||||||
import SettingsInterface from '@src/common/interfaces/SettingsInterface';
|
import SettingsInterface from '@src/common/interfaces/SettingsInterface';
|
||||||
|
import { _cp } from '@src/common/js/utils';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@ -360,7 +361,7 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async loadFromSnapshot(snapshotIndex, skipSnapshot?: boolean) {
|
async loadFromSnapshot(snapshotIndex, skipSnapshot?: boolean) {
|
||||||
this.settings.init({snapshot: this.settingsSnapshots[snapshotIndex], skipSnapshot});
|
this.settings.init({snapshot: _cp(this.settingsSnapshots[snapshotIndex]), skipSnapshot});
|
||||||
},
|
},
|
||||||
|
|
||||||
async testMigration(snapshotIndex) {
|
async testMigration(snapshotIndex) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user