aboutsummaryrefslogtreecommitdiff
path: root/ext/js/pages
diff options
context:
space:
mode:
authorKuuuube <61125188+Kuuuube@users.noreply.github.com>2024-06-18 20:18:43 -0400
committerGitHub <noreply@github.com>2024-06-19 00:18:43 +0000
commit451bcab01fd591ec54b63af0fc7084dc9f37928b (patch)
tree5b7ae78d7187c77f4b12bf377524e837e9b24606 /ext/js/pages
parentc002e585fcbfc89b2c345a10c0663336f31442af (diff)
Add auto option to body theme (#1086)
* Add auto option to body theme * Fix firefox bug where themes do not set correctly in settings due to getOptions failing
Diffstat (limited to 'ext/js/pages')
-rw-r--r--ext/js/pages/action-popup-main.js2
-rw-r--r--ext/js/pages/info-main.js1
-rw-r--r--ext/js/pages/quick-start-guide-main.js1
-rw-r--r--ext/js/pages/settings/popup-preview-frame.js2
-rw-r--r--ext/js/pages/settings/settings-display-controller.js15
5 files changed, 13 insertions, 8 deletions
diff --git a/ext/js/pages/action-popup-main.js b/ext/js/pages/action-popup-main.js
index ce29bcf1..4137d5c3 100644
--- a/ext/js/pages/action-popup-main.js
+++ b/ext/js/pages/action-popup-main.js
@@ -37,7 +37,6 @@ class DisplayController {
/** */
async prepare() {
- this._themeController.siteTheme = 'light';
this._themeController.prepare();
const manifest = chrome.runtime.getManifest();
@@ -209,6 +208,7 @@ class DisplayController {
void this._updatePermissionsWarnings(options);
this._themeController.theme = options.general.popupTheme;
+ this._themeController.siteOverride = true;
this._themeController.updateTheme();
}
diff --git a/ext/js/pages/info-main.js b/ext/js/pages/info-main.js
index f431239f..079a8c3a 100644
--- a/ext/js/pages/info-main.js
+++ b/ext/js/pages/info-main.js
@@ -163,6 +163,7 @@ await Application.main(true, async (application) => {
const primaryProfile = (profileCurrent >= 0 && profileCurrent < profiles.length) ? profiles[profileCurrent] : null;
if (primaryProfile !== null) {
themeController.theme = primaryProfile.options.general.popupTheme;
+ themeController.siteOverride = true;
themeController.updateTheme();
}
diff --git a/ext/js/pages/quick-start-guide-main.js b/ext/js/pages/quick-start-guide-main.js
index 41644f51..6a3cd39b 100644
--- a/ext/js/pages/quick-start-guide-main.js
+++ b/ext/js/pages/quick-start-guide-main.js
@@ -30,6 +30,7 @@ await Application.main(true, async (application) => {
const primaryProfile = (profileCurrent >= 0 && profileCurrent < profiles.length) ? profiles[profileCurrent] : null;
if (primaryProfile !== null) {
themeController.theme = primaryProfile.options.general.popupTheme;
+ themeController.siteOverride = true;
themeController.updateTheme();
}
});
diff --git a/ext/js/pages/settings/popup-preview-frame.js b/ext/js/pages/settings/popup-preview-frame.js
index 7abcfe2a..dc00d091 100644
--- a/ext/js/pages/settings/popup-preview-frame.js
+++ b/ext/js/pages/settings/popup-preview-frame.js
@@ -77,7 +77,6 @@ export class PopupPreviewFrame {
async prepare() {
window.addEventListener('message', this._onMessage.bind(this), false);
- this._themeController.siteTheme = 'light';
this._themeController.prepare();
// Setup events
@@ -141,6 +140,7 @@ export class PopupPreviewFrame {
options.general.popupVerticalTextPosition = 'before';
options.scanning.selectText = false;
this._themeController.theme = options.general.popupTheme;
+ this._themeController.siteOverride = true;
this._themeController.updateTheme();
return options;
}
diff --git a/ext/js/pages/settings/settings-display-controller.js b/ext/js/pages/settings/settings-display-controller.js
index 49f7192c..e179b835 100644
--- a/ext/js/pages/settings/settings-display-controller.js
+++ b/ext/js/pages/settings/settings-display-controller.js
@@ -42,11 +42,12 @@ export class SettingsDisplayController {
this._onMenuButtonClickBind = this._onMenuButtonClick.bind(this);
/** @type {ThemeController} */
this._themeController = new ThemeController(document.documentElement);
+ /** @type {HTMLSelectElement | null}*/
+ this._themeDropdown = document.querySelector('[data-setting="general.popupTheme"]');
}
/** */
prepare() {
- this._themeController.siteTheme = 'light';
this._themeController.prepare();
void this._updateTheme();
@@ -92,16 +93,18 @@ export class SettingsDisplayController {
window.addEventListener('popstate', this._onPopState.bind(this), false);
this._updateScrollTarget();
- const themeDropdown = document.querySelector('[data-setting="general.popupTheme"]');
- if (themeDropdown) {
- themeDropdown.addEventListener('change', this._updateTheme.bind(this), false);
+ if (this._themeDropdown) {
+ this._themeDropdown.addEventListener('change', this._updateTheme.bind(this), false);
}
}
/** */
async _updateTheme() {
- const options = await this._settingsController.getOptions();
- this._themeController.theme = options.general.popupTheme;
+ const theme = this._themeDropdown?.value;
+ if (theme === 'site' || theme === 'light' || theme === 'dark' || theme === 'browser') {
+ this._themeController.theme = theme;
+ }
+ this._themeController.siteOverride = true;
this._themeController.updateTheme();
}