summaryrefslogtreecommitdiff
path: root/ext/bg/js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2021-01-26 18:30:01 -0500
committerGitHub <noreply@github.com>2021-01-26 18:30:01 -0500
commit8d292363d4d7363134a66e6d35e549f4634521a1 (patch)
tree880cad7f3f2e279401af888335d053c6c80b48cf /ext/bg/js
parentd11cd7b28f6837c38a566461dc124799ac6736c9 (diff)
Update clipboard options organization (#1318)
* Update options organization * Update general.enableClipboardPopups to clipboard.enableBackgroundMonitor * Update general.enableClipboardMonitor to clipboard.enableSearchPageMonitor * Update general.maximumClipboardSearchLength to clipboard.maximumSearchLength * Update general.autoSearchClipboardContent to clipboard.autoSearchContent
Diffstat (limited to 'ext/bg/js')
-rw-r--r--ext/bg/js/backend.js8
-rw-r--r--ext/bg/js/options.js17
-rw-r--r--ext/bg/js/search.js12
-rw-r--r--ext/bg/js/settings/clipboard-popups-controller.js10
4 files changed, 28 insertions, 19 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js
index fb0596d5..9a8844c5 100644
--- a/ext/bg/js/backend.js
+++ b/ext/bg/js/backend.js
@@ -233,9 +233,9 @@ class Backend {
// Event handlers
async _onClipboardTextChange({text}) {
- const {general: {maximumClipboardSearchLength}} = this._getProfileOptions({current: true});
- if (text.length > maximumClipboardSearchLength) {
- text = text.substring(0, maximumClipboardSearchLength);
+ const {clipboard: {maximumSearchLength}} = this._getProfileOptions({current: true});
+ if (text.length > maximumSearchLength) {
+ text = text.substring(0, maximumSearchLength);
}
try {
const {tab, created} = await this._getOrCreateSearchPopup();
@@ -912,7 +912,7 @@ class Backend {
this._mecab.stopListener();
}
- if (options.general.enableClipboardPopups) {
+ if (options.clipboard.enableBackgroundMonitor) {
this._clipboardMonitor.start();
} else {
this._clipboardMonitor.stop();
diff --git a/ext/bg/js/options.js b/ext/bg/js/options.js
index 14b858aa..02caa5a2 100644
--- a/ext/bg/js/options.js
+++ b/ext/bg/js/options.js
@@ -669,8 +669,10 @@ class OptionsUtil {
// Updated handlebars templates to include "stroke-count" definition.
// Updated global.useSettingsV2 to be true (opt-out).
// Added audio.customSourceType.
- // Added general.autoSearchClipboardContent.
- // Forced general.enableClipboardMonitor to false due to a bug which caused its value to not be read.
+ // Moved general.enableClipboardPopups => clipboard.enableBackgroundMonitor.
+ // Moved general.enableClipboardMonitor => clipboard.enableSearchPageMonitor. Forced value to false due to a bug which caused its value to not be read.
+ // Moved general.maximumClipboardSearchLength => clipboard.maximumSearchLength.
+ // Added clipboard.autoSearchContent.
await this._addFieldTemplatesToOptions(options, '/bg/data/anki-field-templates-upgrade-v8.handlebars');
options.global.useSettingsV2 = true;
for (const profile of options.profiles) {
@@ -730,8 +732,15 @@ class OptionsUtil {
windowState: 'normal'
};
profile.options.audio.customSourceType = 'audio';
- profile.options.general.autoSearchClipboardContent = true;
- profile.options.general.enableClipboardMonitor = false;
+ profile.options.clipboard = {
+ enableBackgroundMonitor: profile.options.general.enableClipboardPopups,
+ enableSearchPageMonitor: false,
+ autoSearchContent: true,
+ maximumSearchLength: profile.options.general.maximumClipboardSearchLength
+ };
+ delete profile.options.general.enableClipboardPopups;
+ delete profile.options.general.enableClipboardMonitor;
+ delete profile.options.general.maximumClipboardSearchLength;
}
return options;
}
diff --git a/ext/bg/js/search.js b/ext/bg/js/search.js
index c17ae1ac..27cba50f 100644
--- a/ext/bg/js/search.js
+++ b/ext/bg/js/search.js
@@ -126,7 +126,7 @@ class DisplaySearch extends Display {
}
_onDisplayOptionsUpdated({options}) {
- this._clipboardMonitorEnabled = options.general.enableClipboardMonitor;
+ this._clipboardMonitorEnabled = options.clipboard.enableSearchPageMonitor;
this._updateClipboardMonitorEnabled();
}
@@ -182,13 +182,13 @@ class DisplaySearch extends Display {
}
_onExternalSearchUpdate({text, animate=true}) {
- const {general: {maximumClipboardSearchLength, autoSearchClipboardContent}} = this.getOptions();
- if (text.length > maximumClipboardSearchLength) {
- text = text.substring(0, maximumClipboardSearchLength);
+ const {clipboard: {autoSearchContent, maximumSearchLength}} = this.getOptions();
+ if (text.length > maximumSearchLength) {
+ text = text.substring(0, maximumSearchLength);
}
this._queryInput.value = text;
this._updateSearchHeight(true);
- this._search(animate, false, autoSearchClipboardContent);
+ this._search(animate, false, autoSearchContent);
}
_onWanakanaEnableChange(e) {
@@ -303,7 +303,7 @@ class DisplaySearch extends Display {
await api.modifySettings([{
action: 'set',
- path: 'general.enableClipboardMonitor',
+ path: 'clipboard.enableSearchPageMonitor',
value,
scope: 'profile',
optionsContext: this.getOptionsContext()
diff --git a/ext/bg/js/settings/clipboard-popups-controller.js b/ext/bg/js/settings/clipboard-popups-controller.js
index 810b1bc6..fcff444c 100644
--- a/ext/bg/js/settings/clipboard-popups-controller.js
+++ b/ext/bg/js/settings/clipboard-popups-controller.js
@@ -18,11 +18,11 @@
class ClipboardPopupsController {
constructor(settingsController) {
this._settingsController = settingsController;
- this._checkbox = document.querySelector('#enable-clipboard-popups');
+ this._checkbox = document.querySelector('#clipboard-enable-background-monitor');
}
async prepare() {
- this._checkbox.addEventListener('change', this._onEnableClipboardPopupsChanged.bind(this), false);
+ this._checkbox.addEventListener('change', this._onEnableBackgroundMonitorChanged.bind(this), false);
this._settingsController.on('optionsChanged', this._onOptionsChanged.bind(this));
const options = await this._settingsController.getOptions();
@@ -32,10 +32,10 @@ class ClipboardPopupsController {
// Private
_onOptionsChanged({options}) {
- this._checkbox.checked = options.general.enableClipboardPopups;
+ this._checkbox.checked = options.clipboard.enableBackgroundMonitor;
}
- async _onEnableClipboardPopupsChanged(e) {
+ async _onEnableBackgroundMonitorChanged(e) {
const checkbox = e.currentTarget;
let value = checkbox.checked;
@@ -46,6 +46,6 @@ class ClipboardPopupsController {
checkbox.checked = value;
}
- await this._settingsController.setProfileSetting('general.enableClipboardPopups', value);
+ await this._settingsController.setProfileSetting('clipboard.enableBackgroundMonitor', value);
}
}