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:
psvenk 2019-06-30 16:06:06 +00:00 committed by Omar Roth
parent 90cd3571ae
commit 854e9f61c4
No known key found for this signature in database
GPG Key ID: B8254FB7EC3D37F2

View File

@ -38,12 +38,15 @@ function set_mode (bool) {
} }
function update_mode (mode) { function update_mode (mode) {
set_mode( if (mode == 'true' /* for backwards compatibility */ || mode == 'dark') {
mode == 'true' // for backwards compatibility // If dark mode preference set
|| mode == 'dark' set_mode(true);
|| (mode != 'light' }
&& window.matchMedia('(prefers-color-scheme: dark)').matches) 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);
} }