mirror of
https://github.com/iv-org/invidious.git
synced 2025-08-03 19:28:29 +00:00
Make mode setting code clearer
This should clear up some confusion with the way that I had implemented mode setting, making the code more readable.
This commit is contained in:
parent
90cd3571ae
commit
854e9f61c4
@ -38,12 +38,15 @@ function set_mode (bool) {
|
||||
}
|
||||
|
||||
function update_mode (mode) {
|
||||
set_mode(
|
||||
mode == 'true' // for backwards compatibility
|
||||
|| mode == 'dark'
|
||||
|| (mode != 'light'
|
||||
&& window.matchMedia('(prefers-color-scheme: dark)').matches)
|
||||
);
|
||||
if (mode == 'true' /* for backwards compatibility */ || mode == 'dark') {
|
||||
// If dark mode preference set
|
||||
set_mode(true);
|
||||
}
|
||||
else if (mode != 'light' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
// If no preference set, but the browser tells us that the operating system has a dark theme
|
||||
set_mode(true);
|
||||
}
|
||||
else set_mode(false);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user