fix: Fixed issue with system color scheme on mobile

This commit is contained in:
Aman Harwara
2024-03-26 21:08:04 +05:30
parent 8a6e123fbc
commit 45ca99c627

View File

@@ -91,7 +91,7 @@ export class ThemeManager extends AbstractUIService {
break
}
case ApplicationEvent.FeaturesAvailabilityChanged: {
this.handleFeaturesAvailabilityChanged()
this.handleFeaturesAvailabilityChanged().catch(console.error)
break
}
case ApplicationEvent.Launched: {
@@ -197,7 +197,7 @@ export class ThemeManager extends AbstractUIService {
}
}
private handleFeaturesAvailabilityChanged(): void {
private async handleFeaturesAvailabilityChanged() {
let hasChange = false
for (const theme of this.themesActiveInTheUI.asThemes()) {
@@ -219,7 +219,10 @@ export class ThemeManager extends AbstractUIService {
const shouldSetThemeAsPerColorScheme = this.preferences.getLocalValue(LocalPrefKey.UseSystemColorScheme, false)
if (shouldSetThemeAsPerColorScheme) {
const prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches
let prefersDarkColorScheme = window.matchMedia('(prefers-color-scheme: dark)').matches
if (this.application.isNativeMobileWeb()) {
prefersDarkColorScheme = (await this.application.mobileDevice.getColorScheme()) === 'dark'
}
hasChange = this.setThemeAsPerColorScheme(prefersDarkColorScheme)
}