Skip to content

Commit

Permalink
System Automation fix (#9510)
Browse files Browse the repository at this point in the history
- Latest Chrome's background doesn't support matchMedia.
- Did it work for Firefox for the past year?
  • Loading branch information
alexanderby committed Aug 10, 2022
1 parent 573be4f commit 9636997
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
15 changes: 4 additions & 11 deletions src/background/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,9 @@ export class Extension {
}
break;
}
if (isFirefox) {
// BUG: Firefox background page always matches initial color scheme.
isAutoDark = this.wasLastColorSchemeDark == null
? isSystemDarkModeEnabled()
: this.wasLastColorSchemeDark;
} else {
isAutoDark = isSystemDarkModeEnabled();
}
isAutoDark = this.wasLastColorSchemeDark == null
? isSystemDarkModeEnabled()
: this.wasLastColorSchemeDark;
break;
case 'location': {
const {latitude, longitude} = UserStorage.settings.location;
Expand Down Expand Up @@ -392,9 +387,7 @@ export class Extension {

private static onColorSchemeChange = async (isDark: boolean) => {
this.MV3syncSystemColorStateManager(isDark);
if (isFirefox) {
this.wasLastColorSchemeDark = isDark;
}
this.wasLastColorSchemeDark = isDark;
await this.loadData();
if (UserStorage.settings.automation.mode !== 'system') {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/background/tab-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export default class TabManager {
case MessageType.UI_COLOR_SCHEME_CHANGE:
// fallthrough
case MessageType.CS_COLOR_SCHEME_CHANGE:
onColorSchemeChange(message.data);
onColorSchemeChange(message.data.isDark);
break;

case MessageType.UI_SAVE_FILE: {
Expand Down

0 comments on commit 9636997

Please sign in to comment.