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

Fix themes not loading unless signed in

This commit is contained in:
MrTimscampi 2020-08-09 13:24:16 +02:00
parent 784f9fcc32
commit e6159a22d8
2 changed files with 34 additions and 9 deletions

View file

@ -1,21 +1,41 @@
let data;
function getConfig() {
async function getConfig() {
if (data) return Promise.resolve(data);
return fetch('config.json?nocache=' + new Date().getUTCMilliseconds()).then(response => {
data = response.json();
try {
const response = await fetch('config.json', {
cache: 'no-cache'
});
if (!response.ok) {
throw new Error('network response was not ok');
}
data = await response.json();
return data;
}).catch(error => {
console.warn('web config file is missing so the template will be used');
} catch (error) {
console.warn('failed to fetch the web config file:', error);
return getDefaultConfig();
});
}
}
function getDefaultConfig() {
return fetch('config.template.json').then(function (response) {
async function getDefaultConfig() {
try {
const response = await fetch('config.template.json', {
cache: 'no-cache'
});
if (!response.ok) {
throw new Error('network response was not ok');
}
data = response.json();
return data;
});
} catch (error) {
console.error('failed to fetch the default web config file:', error);
}
}
export function getMultiServer() {
@ -29,6 +49,7 @@ export function getMultiServer() {
export function getThemes() {
return getConfig().then(config => {
console.warn(config.themes);
return config.themes;
}).catch(error => {
console.log('cannot get web config:', error);