Skip to content

Commit

Permalink
fix: remove tab border color in firefox 89
Browse files Browse the repository at this point in the history
  • Loading branch information
Frewacom committed Jun 6, 2021
1 parent ae2831a commit 159d6d2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/background/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
30 changes: 27 additions & 3 deletions src/background/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
ThemeModes,
TemplateTypes,
ColorschemeTypes,
PaletteColors,
} from '@definitions';

import { DEFAULT_CSS_FONT_SIZE } from '@config/general';
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/config/default-themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 159d6d2

Please sign in to comment.