feat: Use user color scheme by default if no cookie was found (#477)

* feat: Use user color scheme by default if no cookie was found

* Update settings.js
This commit is contained in:
nikitaa01 2024-06-17 19:27:21 +02:00 committed by GitHub
parent 056b3f8dfc
commit 28b6e4cb74
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,7 +30,8 @@ export class Settings
LoadFromCookies ()
{
this.themeId = CookieGetIntVal ('ov_theme_id', Theme.Light);
const preferredColorScheme = window.matchMedia ('(prefers-color-scheme: dark)').matches ? Theme.Dark : Theme.Light;
this.themeId = CookieGetIntVal ('ov_theme_id', preferredColorScheme);
this.environmentMapName = CookieGetStringVal ('ov_environment_map', 'fishermans_bastion');
this.backgroundIsEnvMap = CookieGetBoolVal ('ov_background_is_envmap', false);
this.backgroundColor = CookieGetRGBAColorVal ('ov_background_color', new RGBAColor (255, 255, 255, 255));