1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

fixed bugs for default theme handling

fixed import for headroom.js
This commit is contained in:
vitorsemeano 2020-11-08 11:39:46 +00:00
parent 194bbf1ff1
commit b23e625c20
3 changed files with 30 additions and 17 deletions

View file

@ -17,6 +17,7 @@ import '../assets/css/scrollstyles.css';
import '../assets/css/flexstyles.scss';
import Dashboard from './clientUtils';
import ServerConnections from '../components/ServerConnections';
import Headroom from 'headroom.js';
/* eslint-disable indent */
@ -801,10 +802,8 @@ import ServerConnections from '../components/ServerConnections';
}
function initHeadRoom(elem) {
import('headroom.js').then((Headroom) => {
const headroom = new Headroom(elem);
headroom.init();
});
}
function refreshLibraryDrawer(user) {

View file

@ -85,35 +85,41 @@ export function getMultiServer() {
});
}
const defaultTheme = {
const baseDefaultTheme = {
'name': 'Dark',
'id': 'dark',
'default': true
};
let internalDefaultTheme = baseDefaultTheme;
const checkDefaultTheme = (themes) => {
if (themes) {
const defaultTheme = themes.find((theme) => theme.default);
if (!defaultTheme) {
themes.push(defaultTheme);
if (defaultTheme) {
internalDefaultTheme = defaultTheme;
return;
}
}
return themes;
}
return [defaultTheme];
internalDefaultTheme = baseDefaultTheme;
};
export function getThemes() {
return getConfig().then(config => {
return checkDefaultTheme(Array.isArray(config.themes) ? config.themes : []);
const themes = Array.isArray(config.themes) ? config.themes : [];
checkDefaultTheme(themes);
return themes;
}).catch(error => {
console.log('cannot get web config:', error);
return checkDefaultTheme();
checkDefaultTheme();
return [];
});
}
export const getDefaultTheme = () => internalDefaultTheme;
export function getPlugins() {
return getConfig().then(config => {
return config.plugins;

View file

@ -1,4 +1,4 @@
import * as webSettings from './settings/webSettings';
import { getDefaultTheme, getThemes as getConfiguredThemes } from './settings/webSettings';
let themeStyleElement = document.querySelector('#cssTheme');
let currentThemeId;
@ -12,14 +12,22 @@ function unloadTheme() {
}
function getThemes() {
return webSettings.getThemes();
return getConfiguredThemes();
}
function getThemeStylesheetInfo(id) {
return getThemes().then(themes => {
const theme = themes.find(theme => {
return id ? theme.id === id : theme.default;
let theme;
if (id) {
theme = themes.find(theme => {
return theme.id === id;
});
}
if (!theme) {
theme = getDefaultTheme();
}
return {
stylesheetPath: 'themes/' + theme.id + '/theme.css',