From 159d6d2ece96a0ac00495691ddad266e23e2e1ac Mon Sep 17 00:00:00 2001 From: Fredrik Engstrand Date: Sun, 6 Jun 2021 11:34:43 +0200 Subject: [PATCH] fix: remove tab border color in firefox 89 --- src/background/extension.ts | 2 +- src/background/state.ts | 30 +++++++++++++++++++++++++++--- src/config/default-themes.ts | 2 +- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/background/extension.ts b/src/background/extension.ts index 83eb0d8..be29de0 100644 --- a/src/background/extension.ts +++ b/src/background/extension.ts @@ -654,7 +654,7 @@ export default class Extension { this.updatePage = new ExtensionPage(EXTENSION_PAGES.UPDATE); this.nativeErrorPage = new ExtensionPage(EXTENSION_PAGES.NATIVE_ERROR); - this.stateLoadPromise = this.state.load(); + this.stateLoadPromise = this.state.load(this.updateThemeForCurrentMode.bind(this)); await this.stateLoadPromise; this.stateLoadPromise = null; diff --git a/src/background/state.ts b/src/background/state.ts index 9e39b8a..bf76294 100644 --- a/src/background/state.ts +++ b/src/background/state.ts @@ -18,6 +18,7 @@ import { ThemeModes, TemplateTypes, ColorschemeTypes, + PaletteColors, } from '@definitions'; import { DEFAULT_CSS_FONT_SIZE } from '@config/general'; @@ -53,7 +54,7 @@ export default class State { fontSize: DEFAULT_CSS_FONT_SIZE, duckduckgo: false, darkreader: false, - fetchOnStartup: false, + fetchOnStartup: true, autoTimeStart: { hour: 10, minute: 0, stringFormat: '10:00' }, autoTimeEnd: { hour: 19, minute: 0, stringFormat: '19:00' }, updateMuted: false, @@ -401,14 +402,37 @@ export default class State { }); } - public async load() { + public async load(themeRefreshCallback: () => void) { + let shouldRefresh = false + const browserInfo = await browser.runtime.getBrowserInfo() this.currentState = await browser.storage.local.get(this.initialState); // Temporary state migration until a real migration system is implemented if (this.getTemplate().duckduckgo.hasOwnProperty('modifier')) { this.currentState.theme.templates.dark.duckduckgo = DEFAULT_THEME_DARK.duckduckgo; this.currentState.theme.templates.light.duckduckgo = DEFAULT_THEME_LIGHT.duckduckgo; - await browser.storage.local.set(this.currentState); + } + + // Fix for v89 tab border + if (browserInfo?.version && browserInfo.version.split('.')[0] === '89') { + const { dark, light } = this.currentState.theme.templates + + // We make sure to only change this property if it has not been modified by the user + if (dark.browser.tab_line === PaletteColors.AccentPrimary) { + this.currentState.theme.templates.dark.browser.tab_line = PaletteColors.BackgroundLight + shouldRefresh = true + } + + if (light.browser.tab_line === PaletteColors.AccentPrimary) { + this.currentState.theme.templates.light.browser.tab_line = PaletteColors.BackgroundLight + shouldRefresh = true + } + } + + await browser.storage.local.set(this.currentState); + + if (shouldRefresh) { + themeRefreshCallback() } } diff --git a/src/config/default-themes.ts b/src/config/default-themes.ts index 616bfdc..861429a 100644 --- a/src/config/default-themes.ts +++ b/src/config/default-themes.ts @@ -60,7 +60,7 @@ export const BASE_BROWSER_TEMPLATE = { tab_loading: PaletteColors.AccentPrimary, tab_background_text: PaletteColors.Text, tab_selected: PaletteColors.BackgroundLight, - tab_line: PaletteColors.AccentPrimary, + tab_line: PaletteColors.BackgroundLight, toolbar: PaletteColors.BackgroundLight, toolbar_field_text: PaletteColors.Text, toolbar_field_text_focus: PaletteColors.TextFocus,