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/autoThemes.js

26 lines
981 B
JavaScript
Raw Normal View History

2020-08-14 08:46:34 +02:00
import * as userSettings from './settings/userSettings';
import skinManager from './themeManager';
import { Events } from 'jellyfin-apiclient';
import ServerConnections from '../components/ServerConnections';
2020-12-21 10:38:54 -05:00
import { pageClassOn } from '../scripts/clientUtils';
// Set the default theme when loading
2020-09-26 21:48:22 +03:00
skinManager.setTheme(userSettings.theme())
/* this keeps the scrollbar always present in all pages, so we avoid clipping while switching between pages
2020-09-26 21:48:22 +03:00
that need the scrollbar and pages that don't.
*/
.then(() => document.body.classList.add('force-scroll'));
2020-10-25 20:20:06 +09:00
// set the saved theme once a user authenticates
2020-12-21 10:38:54 -05:00
Events.on(ServerConnections, 'localusersignedin', () => {
skinManager.setTheme(userSettings.theme());
});
2020-12-21 10:38:54 -05:00
pageClassOn('viewbeforeshow', 'page', function () {
if (this.classList.contains('type-interior')) {
skinManager.setTheme(userSettings.dashboardTheme());
} else {
skinManager.setTheme(userSettings.theme());
}
});