1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-30 13:03:53 +01:00

Use Mql.addListener for backwards compat (Safari < v14) (#1304)

This commit is contained in:
Daniel James Smith 2021-11-18 19:03:20 +01:00 committed by GitHub
parent d6c419bad8
commit 977fdef787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -156,7 +156,7 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
} }
supportsWebAuthn(win: Window): boolean { supportsWebAuthn(win: Window): boolean {
return (typeof(PublicKeyCredential) !== 'undefined'); return (typeof (PublicKeyCredential) !== 'undefined');
} }
supportsDuo(): boolean { supportsDuo(): boolean {
@ -304,8 +304,15 @@ export class WebPlatformUtilsService implements PlatformUtilsService {
} }
onDefaultSystemThemeChange(callback: ((theme: ThemeType.Light | ThemeType.Dark) => unknown)) { onDefaultSystemThemeChange(callback: ((theme: ThemeType.Light | ThemeType.Dark) => unknown)) {
try {
this.prefersColorSchemeDark.addEventListener('change', ({ matches }) => { this.prefersColorSchemeDark.addEventListener('change', ({ matches }) => {
callback(matches ? ThemeType.Dark : ThemeType.Light); callback(matches ? ThemeType.Dark : ThemeType.Light);
}); });
} catch (e) {
// Safari older than v14
this.prefersColorSchemeDark.addListener(ev => {
callback(ev.matches ? ThemeType.Dark : ThemeType.Light);
});
}
} }
} }