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

51 lines
1 KiB
JavaScript
Raw Normal View History

import { getDefaultTheme, getThemes as getConfiguredThemes } from './settings/webSettings';
2020-10-07 21:12:14 +09:00
let currentThemeId;
function getThemes() {
return getConfiguredThemes();
}
function getThemeStylesheetInfo(id) {
return getThemes().then(themes => {
let theme;
if (id) {
2020-11-08 20:56:08 +00:00
theme = themes.find(currentTheme => {
return currentTheme.id === id;
});
}
if (!theme) {
theme = getDefaultTheme();
}
return theme;
});
}
function setTheme(id) {
2021-01-26 22:20:12 -05:00
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;
2021-09-23 23:33:05 -04:00
document.getElementById('themeColor').content = info.color;
});
});
}
export default {
getThemes,
setTheme
};