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/settings/webSettings.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-04-02 19:44:21 +09:00
let data;
2020-04-02 03:51:22 +09:00
function getConfig() {
2020-04-02 19:44:21 +09:00
if (data) return Promise.resolve(data);
2020-06-04 20:41:26 +02:00
return fetch('config.json?nocache=' + new Date().getUTCMilliseconds()).then(response => {
2020-05-12 06:28:14 +09:00
data = response.json();
return data;
}).catch(error => {
2020-05-13 10:50:04 +09:00
console.warn('web config file is missing so the template will be used');
2020-05-12 06:28:14 +09:00
return getDefaultConfig();
});
}
function getDefaultConfig() {
2020-06-04 20:41:26 +02:00
return fetch('config.template.json').then(function (response) {
2020-04-02 19:50:09 +09:00
data = response.json();
return data;
2020-04-02 03:51:22 +09:00
});
}
export function getMultiServer() {
2020-04-02 03:51:22 +09:00
return getConfig().then(config => {
return config.multiserver;
2020-04-24 13:46:57 +03:00
}).catch(error => {
2020-05-04 12:44:12 +02:00
console.log('cannot get web config:', error);
2020-04-24 13:46:57 +03:00
return false;
2020-04-02 03:51:22 +09:00
});
}
export function getThemes() {
return getConfig().then(config => {
return config.themes;
}).catch(error => {
console.log('cannot get web config:', error);
return [];
});
}
export function getPlugins() {
return getConfig().then(config => {
return config.plugins;
}).catch(error => {
console.log('cannot get web config:', error);
return [];
});
}