add colorScheme.isDark()
This commit is contained in:
parent
bef70f6db3
commit
1364d3a8ba
|
@ -34,13 +34,12 @@ const colorScheme = (() => {
|
|||
onChange(listener) {
|
||||
changeListeners.add(listener);
|
||||
},
|
||||
/** @param {StyleObj | 'darkUI'} val - the string is used by the built-in dark themer */
|
||||
shouldIncludeStyle(val) {
|
||||
return val === 'darkUI'
|
||||
? isDarkNow
|
||||
: prefs.get(kSTATE) === 'never' ||
|
||||
!SCHEMES.includes(val = val.preferScheme) ||
|
||||
isDarkNow === (val === 'dark');
|
||||
isDark: () => isDarkNow,
|
||||
/** @param {StyleObj} _ */
|
||||
shouldIncludeStyle({preferScheme: ps}) {
|
||||
return prefs.get(kSTATE) === 'never' ||
|
||||
!SCHEMES.includes(ps) ||
|
||||
isDarkNow === (ps === 'dark');
|
||||
},
|
||||
updateSystemPreferDark(val) {
|
||||
update('system', val);
|
||||
|
|
|
@ -11,11 +11,10 @@
|
|||
* and not even a problem in the most popular case of using system dark/light mode.
|
||||
*/
|
||||
|
||||
API.colorScheme.shouldIncludeStyle('darkUI').then(val => {
|
||||
API.colorScheme.isDark().then(isDark => {
|
||||
const ON = 'screen';
|
||||
const OFF = 'not all';
|
||||
const map = {[ON]: true, [OFF]: false};
|
||||
let isDark = val;
|
||||
toggleDarkStyles();
|
||||
msg.onExtension(e => {
|
||||
if (e.method === 'colorScheme') {
|
||||
|
|
Loading…
Reference in New Issue
Block a user