bug: fix changing theme through UPO (#340)

This commit is contained in:
H. C. Kruse 2021-04-06 14:40:15 +02:00 committed by GitHub
parent abffe590b5
commit 0e63bb6aef
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View file

@ -55,12 +55,10 @@ final class Theme extends Partial {
$this->out->addHtmlClasses( 'skin-citizen-' . $theme );
// Add styles and scripts module
if ( $theme === 'auto' ) {
$options['scripts'] = array_merge(
$options['scripts'],
[ 'skins.citizen.scripts.theme' ]
);
}
$options['scripts'] = array_merge(
$options['scripts'],
[ 'skins.citizen.scripts.theme' ]
);
$options['styles'] = array_merge(
$options['styles'],

View file

@ -22,6 +22,12 @@
return;
}
try {
if ( window.mw.cookie.get( 'skin-citizen-theme-override' ) === '1' ) {
return;
}
} catch ( e ) {}
theme = window.mw.config.get( 'wgCitizenThemeDefault' );
if ( theme === null ) {
theme = 'auto';
@ -34,15 +40,10 @@
}
if ( theme !== 'auto' ) {
setStorageChangeTheme( theme );
return;
}
try {
if ( window.mw.cookie.get( 'skin-citizen-theme-override' ) === '1' ) {
return;
}
} catch ( e ) {}
prefersColorSchemeDarkQuery = window.matchMedia( '(prefers-color-scheme: dark)' );
theme = 'light';
if ( prefersColorSchemeDarkQuery.matches ) {