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

View file

@ -85,35 +85,41 @@ export function getMultiServer() {
}); });
} }
const defaultTheme = { const baseDefaultTheme = {
'name': 'Dark', 'name': 'Dark',
'id': 'dark', 'id': 'dark',
'default': true 'default': true
}; };
let internalDefaultTheme = baseDefaultTheme;
const checkDefaultTheme = (themes) => { const checkDefaultTheme = (themes) => {
if (themes) { if (themes) {
const defaultTheme = themes.find((theme) => theme.default); const defaultTheme = themes.find((theme) => theme.default);
if (!defaultTheme) { if (defaultTheme) {
themes.push(defaultTheme); internalDefaultTheme = defaultTheme;
return;
}
} }
return themes; internalDefaultTheme = baseDefaultTheme;
}
return [defaultTheme];
}; };
export function getThemes() { export function getThemes() {
return getConfig().then(config => { 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 => { }).catch(error => {
console.log('cannot get web config:', error); console.log('cannot get web config:', error);
return checkDefaultTheme(); checkDefaultTheme();
return [];
}); });
} }
export const getDefaultTheme = () => internalDefaultTheme;
export function getPlugins() { export function getPlugins() {
return getConfig().then(config => { return getConfig().then(config => {
return config.plugins; 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 themeStyleElement = document.querySelector('#cssTheme');
let currentThemeId; let currentThemeId;
@ -12,14 +12,22 @@ function unloadTheme() {
} }
function getThemes() { function getThemes() {
return webSettings.getThemes(); return getConfiguredThemes();
} }
function getThemeStylesheetInfo(id) { function getThemeStylesheetInfo(id) {
return getThemes().then(themes => { return getThemes().then(themes => {
const theme = themes.find(theme => { let theme;
return id ? theme.id === id : theme.default;
if (id) {
theme = themes.find(theme => {
return theme.id === id;
}); });
}
if (!theme) {
theme = getDefaultTheme();
}
return { return {
stylesheetPath: 'themes/' + theme.id + '/theme.css', stylesheetPath: 'themes/' + theme.id + '/theme.css',