all: sync with master; upd chlog
This commit is contained in:
@@ -25,6 +25,7 @@ import {
|
||||
STANDARD_HTTPS_PORT,
|
||||
STANDARD_WEB_PORT,
|
||||
SPECIAL_FILTER_ID,
|
||||
THEMES,
|
||||
} from './constants';
|
||||
|
||||
/**
|
||||
@@ -388,6 +389,12 @@ export const toggleAllServices = (services, change, isSelected) => {
|
||||
services.forEach((service) => change(`blocked_services.${service.id}`, isSelected));
|
||||
};
|
||||
|
||||
export const msToSeconds = (milliseconds) => Math.floor(milliseconds / 1000);
|
||||
|
||||
export const msToMinutes = (milliseconds) => Math.floor(milliseconds / 1000 / 60);
|
||||
|
||||
export const msToHours = (milliseconds) => Math.floor(milliseconds / 1000 / 60 / 60);
|
||||
|
||||
export const secondsToMilliseconds = (seconds) => {
|
||||
if (seconds) {
|
||||
return seconds * 1000;
|
||||
@@ -396,6 +403,8 @@ export const secondsToMilliseconds = (seconds) => {
|
||||
return seconds;
|
||||
};
|
||||
|
||||
export const msToDays = (milliseconds) => Math.floor(milliseconds / 1000 / 60 / 60 / 24);
|
||||
|
||||
export const normalizeRulesTextarea = (text) => text?.replace(/^\n/g, '')
|
||||
.replace(/\n\s*\n/g, '\n');
|
||||
|
||||
@@ -676,7 +685,14 @@ export const setHtmlLangAttr = (language) => {
|
||||
* @param theme
|
||||
*/
|
||||
export const setUITheme = (theme) => {
|
||||
document.body.dataset.theme = theme;
|
||||
let currentTheme = theme;
|
||||
|
||||
if (currentTheme === THEMES.auto) {
|
||||
const prefersDark = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
|
||||
currentTheme = prefersDark ? THEMES.dark : THEMES.light;
|
||||
}
|
||||
|
||||
document.body.dataset.theme = currentTheme;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user