From ab425572835d99b48fa849f955dda8808284b685 Mon Sep 17 00:00:00 2001 From: Tamius Han Date: Mon, 28 Oct 2019 22:10:15 +0100 Subject: [PATCH] Fixes for crop mode persistence on the popup side of things --- src/ext/conf/ExtensionConf.js | 2 +- src/ext/lib/ActionHandler.js | 10 ++++++++-- src/ext/lib/Settings.js | 2 +- src/popup/js/ExecAction.js | 12 +++++++++--- src/popup/panels/DefaultSettingsPanel.vue | 6 +++--- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/src/ext/conf/ExtensionConf.js b/src/ext/conf/ExtensionConf.js index adf08e5..b0c3f97 100644 --- a/src/ext/conf/ExtensionConf.js +++ b/src/ext/conf/ExtensionConf.js @@ -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, diff --git a/src/ext/lib/ActionHandler.js b/src/ext/lib/ActionHandler.js index 9db4a2e..8b30499 100644 --- a/src/ext/lib/ActionHandler.js +++ b/src/ext/lib/ActionHandler.js @@ -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,8 +255,15 @@ 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(); } - this.settings.save(); } } diff --git a/src/ext/lib/Settings.js b/src/ext/lib/Settings.js index 508fca3..4cd3e1c 100644 --- a/src/ext/lib/Settings.js +++ b/src/ext/lib/Settings.js @@ -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) { diff --git a/src/popup/js/ExecAction.js b/src/popup/js/ExecAction.js index 03cb516..46a60f4 100644 --- a/src/popup/js/ExecAction.js +++ b/src/popup/js/ExecAction.js @@ -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,8 +65,14 @@ 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(); } - this.settings.save(); } } } diff --git a/src/popup/panels/DefaultSettingsPanel.vue b/src/popup/panels/DefaultSettingsPanel.vue index 4754e8f..afa3229 100644 --- a/src/popup/panels/DefaultSettingsPanel.vue +++ b/src/popup/panels/DefaultSettingsPanel.vue @@ -31,7 +31,7 @@
Persists crop mode :