jellyfish-web/src/scripts/autoThemes.js

24 lines
798 B
JavaScript
Raw Normal View History

2020-08-14 08:46:34 +02:00
import * as userSettings from './settings/userSettings';
import * as webSettings from './settings/webSettings';
import skinManager from './themeManager';
import { Events } from 'jellyfin-apiclient';
import ServerConnections from '../components/ServerConnections';
2020-10-25 20:20:06 +09:00
// set the default theme when loading
skinManager.setTheme(userSettings.theme());
2020-10-25 20:20:06 +09:00
// set the saved theme once a user authenticates
Events.on(ServerConnections, 'localusersignedin', function (e, user) {
skinManager.setTheme(userSettings.theme());
});
2020-10-25 20:20:06 +09:00
webSettings.getFonts().then(fonts => {
for (const font of fonts) {
2020-10-25 20:24:40 +09:00
const link = document.createElement('link');
2020-10-25 20:20:06 +09:00
link.setAttribute('rel', 'stylesheet');
link.href = font;
document.getElementsByTagName('head')[0].appendChild(link);
}
});