1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00
jellyfin-web/src/scripts/themeManager.js
2025-03-24 01:07:51 -04:00

50 lines
1 KiB
JavaScript

import { getDefaultTheme, getThemes as getConfiguredThemes } from './settings/webSettings';
let currentThemeId;
function getThemes() {
return getConfiguredThemes();
}
function getThemeStylesheetInfo(id) {
return getThemes().then(themes => {
let theme;
if (id) {
theme = themes.find(currentTheme => {
return currentTheme.id === id;
});
}
if (!theme) {
theme = getDefaultTheme();
}
return theme;
});
}
function setTheme(id) {
return new Promise(function (resolve) {
if (currentThemeId && currentThemeId === id) {
resolve();
return;
}
getThemeStylesheetInfo(id).then(function (info) {
if (currentThemeId && currentThemeId === info.id) {
resolve();
return;
}
currentThemeId = info.id;
document.getElementById('themeColor').content = info.color;
});
});
}
export default {
getThemes,
setTheme
};