Patching for v4.4.0
This commit is contained in:
parent
5becf0bdf0
commit
dbc35ccbd1
@ -117,7 +117,132 @@ const ExtensionConfPatch = [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}, {
|
||||||
|
forVersion: '4.4.0',
|
||||||
|
updateFn: (userOptions, defaultOptions) => {
|
||||||
|
// remove 'press P to toggle panning mode' thing
|
||||||
|
const togglePan = userOptions.actions.find(x => x.cmd && x.cmd.length === 1 && x.cmd[0].action === 'toggle-pan');
|
||||||
|
if (togglePan) {
|
||||||
|
togglePan.scopes = {};
|
||||||
|
}
|
||||||
|
|
||||||
|
// add new actions
|
||||||
|
userOptions.actions.push({
|
||||||
|
name: 'Don\'t persist crop',
|
||||||
|
label: 'Never persist',
|
||||||
|
cmd: [{
|
||||||
|
action: 'set-ar-persistence',
|
||||||
|
arg: 0,
|
||||||
|
}],
|
||||||
|
scopes: {
|
||||||
|
site: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
playerUi: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'Persist crop while on page',
|
||||||
|
label: 'Until page load',
|
||||||
|
cmd: [{
|
||||||
|
action: 'set-ar-persistence',
|
||||||
|
arg: 1,
|
||||||
|
}],
|
||||||
|
scopes: {
|
||||||
|
site: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
playerUi: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'Persist crop for current session',
|
||||||
|
label: 'Current session',
|
||||||
|
cmd: [{
|
||||||
|
action: 'set-ar-persistence',
|
||||||
|
arg: 2,
|
||||||
|
}],
|
||||||
|
scopes: {
|
||||||
|
site: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
playerUi: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'Persist until manually reset',
|
||||||
|
label: 'Always persist',
|
||||||
|
cmd: [{
|
||||||
|
action: 'set-ar-persistence',
|
||||||
|
arg: 3,
|
||||||
|
}],
|
||||||
|
scopes: {
|
||||||
|
site: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
global: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
playerUi: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
name: 'Default crop persistence',
|
||||||
|
label: 'Default',
|
||||||
|
cmd: [{
|
||||||
|
action: 'set-ar-persistence',
|
||||||
|
arg: -1,
|
||||||
|
}],
|
||||||
|
scopes: {
|
||||||
|
site: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
playerUi: {
|
||||||
|
show: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// patch shortcuts for non-latin layouts, but only if the user hasn't changed default keys
|
||||||
|
for (const action of userOptions.actions) {
|
||||||
|
if (!action.cmd || action.cmd.length !== 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// if this fails, then action doesn't have keyboard shortcut associated with it, so we skip it
|
||||||
|
|
||||||
|
const actionDefaults = defaultOptions.actions.find(x => x.cmd && x.cmd.length === 1 // (redundant, default actions have exactly 1 cmd in array)
|
||||||
|
&& x.cmd[0].action === action.cmd[0].action
|
||||||
|
&& x.scopes.page
|
||||||
|
&& x.scopes.page.shortcut
|
||||||
|
&& x.scopes.page.shortcut.length === 1
|
||||||
|
&& x.scopes.page.shortcut[0].key === action.scopes.page.shortcut[0].key // this can throw exception, and it's okay
|
||||||
|
);
|
||||||
|
if (actionDefaults === undefined) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// update 'code' property for shortcut
|
||||||
|
action.scopes.page.shortcut[0]['code'] = actionDefaults.scopes.page.shortcut[0].code;
|
||||||
|
} catch (e) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
export default ExtensionConfPatch;
|
export default ExtensionConfPatch;
|
@ -385,7 +385,7 @@ var ExtensionConf = {
|
|||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: 'Persist crop while on page',
|
name: 'Persist crop while on page',
|
||||||
label: 'While on page',
|
label: 'Until page load',
|
||||||
cmd: [{
|
cmd: [{
|
||||||
action: 'set-ar-persistence',
|
action: 'set-ar-persistence',
|
||||||
arg: CropModePersistence.UntilPageReload,
|
arg: CropModePersistence.UntilPageReload,
|
||||||
@ -438,7 +438,7 @@ var ExtensionConf = {
|
|||||||
show: true,
|
show: true,
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
name: 'Default persistence',
|
name: 'Default crop persistence',
|
||||||
label: 'Default',
|
label: 'Default',
|
||||||
cmd: [{
|
cmd: [{
|
||||||
action: 'set-ar-persistence',
|
action: 'set-ar-persistence',
|
||||||
|
@ -144,13 +144,29 @@ class Settings {
|
|||||||
// apply all remaining patches
|
// apply all remaining patches
|
||||||
this.logger.log('info', 'settings', `[Settings::applySettingsPatches] There are ${patches.length - index} settings patches to apply`);
|
this.logger.log('info', 'settings', `[Settings::applySettingsPatches] There are ${patches.length - index} settings patches to apply`);
|
||||||
while (index < patches.length) {
|
while (index < patches.length) {
|
||||||
|
const updateFn = patches[index].updateFn;
|
||||||
delete patches[index].forVersion;
|
delete patches[index].forVersion;
|
||||||
ObjectCopy.overwrite(this.active, patches[index]);
|
delete patches[index].updateFn;
|
||||||
|
|
||||||
|
if (Object.keys(patches[index]).length > 0) {
|
||||||
|
ObjectCopy.overwrite(this.active, patches[index]);
|
||||||
|
}
|
||||||
|
if (updateFn) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
updateFn(this.active, this.getDefaultSettings());
|
||||||
|
} catch (e) {
|
||||||
|
console.log("!!!!", e)
|
||||||
|
this.logger.log('error', 'settings', '[Settings::applySettingsPatches] Failed to execute update function. Keeping settings object as-is. Error:', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async init() {
|
async init() {
|
||||||
|
console.log("settngs init")
|
||||||
const settings = await this.get();
|
const settings = await this.get();
|
||||||
this.version = this.getExtensionVersion();
|
this.version = this.getExtensionVersion();
|
||||||
|
|
||||||
@ -267,8 +283,10 @@ class Settings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async set(extensionConf) {
|
async set(extensionConf, options) {
|
||||||
extensionConf.version = this.version;
|
if (!options || !options.forcePreserveVersion) {
|
||||||
|
extensionConf.version = this.version;
|
||||||
|
}
|
||||||
|
|
||||||
this.logger.log('info', 'settings', "[Settings::set] setting new settings:", extensionConf)
|
this.logger.log('info', 'settings', "[Settings::set] setting new settings:", extensionConf)
|
||||||
|
|
||||||
@ -287,12 +305,12 @@ class Settings {
|
|||||||
this.active[prop] = value;
|
this.active[prop] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
async save() {
|
async save(options) {
|
||||||
if (Debug.debug && Debug.storage) {
|
if (Debug.debug && Debug.storage) {
|
||||||
console.log("[Settings::save] Saving active settings:", this.active);
|
console.log("[Settings::save] Saving active settings:", this.active);
|
||||||
}
|
}
|
||||||
this.active.preventReload = undefined;
|
this.active.preventReload = undefined;
|
||||||
await this.set(this.active);
|
await this.set(this.active, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ export default {
|
|||||||
if (this.hasError) {
|
if (this.hasError) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.settings.save();
|
this.settings.save({forcePreserveVersion: true});
|
||||||
// this.parsedSettings = JSON.stringify(this.settings.active, null, 2);
|
// this.parsedSettings = JSON.stringify(this.settings.active, null, 2);
|
||||||
// this.lastSettings = JSON.parse(JSON.stringify(this.settings.active));
|
// this.lastSettings = JSON.parse(JSON.stringify(this.settings.active));
|
||||||
const ths = this;
|
const ths = this;
|
||||||
|
Loading…
Reference in New Issue
Block a user