all: sync with master; upd chlog

This commit is contained in:
Ainar Garipov
2023-04-12 14:48:42 +03:00
parent 0dad53b5f7
commit d9c57cdd9a
181 changed files with 6992 additions and 3430 deletions

View File

@@ -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;
};
/**