Fixes for crop mode persistence on the popup side of things

This commit is contained in:
Tamius Han 2019-10-28 22:10:15 +01:00
parent 5e20925ec5
commit ab42557283
5 changed files with 22 additions and 10 deletions

View File

@ -403,7 +403,7 @@ var ExtensionConf = {
}
}, {
name: 'Persist crop for current session',
label: 'Always persist',
label: 'Current session',
cmd: [{
action: 'set-ar-persistence',
arg: CropModePersistence.CurrentSession,

View File

@ -158,7 +158,6 @@ class ActionHandler {
"\nevent:", event,
"\nevent.target:", event.target
);
}
// lately youtube has allowed you to read and write comments while watching video in
@ -256,10 +255,17 @@ class ActionHandler {
this.settings.active.sites[site].arStatus = cmd.arg;
} else if (cmd.action === 'set-keyboard') {
this.settings.active.sites[site].keyboardShortcutsEnabled = cmd.arg;
} else if (cmd.action === 'set-ar-persistence') {
this.settings.active.sites[site]['cropModePersistence'] = cmd.arg;
this.pageInfo.setArPersistence(cmd.arg);
this.settings.saveWithoutReload();
}
if (cmd.action !== 'set-ar-persistence') {
this.settings.save();
}
}
}
// če smo našli dejanje za to tipko, potem ne preiskujemo naprej
// if we found an action for this key, we stop searching for a match

View File

@ -41,7 +41,7 @@ class Settings {
}
const parsedSettings = JSON.parse(changes.uwSettings.newValue);
if(changes['uwSettings'] && changes['uwSettings'].newValue) {
ths.setActive(parsedSettings);
this.setActive(parsedSettings);
}
if(!parsedSettings.preventReload && this.updateCallback) {

View File

@ -29,11 +29,11 @@ class ExecAction {
// set-ar-persistence sends stuff to content scripts as well (!)
// it's important to do that BEFORE the save step
if (cmd === 'set-ar-persistence') {
if (cmd.action === 'set-ar-persistence') {
// even when setting global defaults, we only send message to the current tab in
// order to avoid problems related to
const message = {
forwardToContentScript: true,
forwardToActive: true,
targetFrame: frame,
frame: frame,
cmd: cmd.action,
@ -65,11 +65,17 @@ class ExecAction {
this.settings.active.sites[site].autoar = cmd.arg;
} else if (cmd.action === 'set-keyboard') {
this.settings.active.sites[site].keyboardShortcutsEnabled = cmd.arg;
} else if (cmd.action === 'set-ar-persistence') {
this.settings.active.sites[site]['cropModePersistence'] = cmd.arg;
this.settings.saveWithoutReload();
}
if (cmd.action !== 'set-ar-persistence') {
this.settings.save();
}
}
}
}
}
export default ExecAction;

View File

@ -31,7 +31,7 @@
<div class="flex flex-row flex-wrap">
<ShortcutButton v-for="(action, index) of aardActions"
class="flex flex-grow button"
:class="{'setting-selected': getCurrent('cropModePersistence') === action.cmd[0].arg}"
:class="{'setting-selected': getCurrent('autoar') === action.cmd[0].arg}"
:key="index"
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
:shortcut="parseShortcut(action)"
@ -49,8 +49,8 @@
<div class="label">Persists crop mode <template v-if="scope === 'site'">for {{site}}</template>:</div>
<div class="flex flex-row flex-wrap">
<ShortcutButton v-for="(action, index) of cropModePersistenceActions"
class="flex flex-grow button"
:class="{'setting-selected': getCurrent('autoar') === action.cmd[0].arg}"
class="flex flex-grow button b3"
:class="{'setting-selected': getCurrent('cropModePersistence') === action.cmd[0].arg}"
:key="index"
:label="(action.scopes[scope] && action.scopes[scope].label) ? action.scopes[scope].label : action.label"
:shortcut="parseShortcut(action)"