2020-08-14 08:46:34 +02:00
|
|
|
import * as userSettings from './settings/userSettings';
|
|
|
|
import skinManager from './themeManager';
|
2020-10-17 19:08:56 +01:00
|
|
|
import { Events } from 'jellyfin-apiclient';
|
|
|
|
import ServerConnections from '../components/ServerConnections';
|
2020-12-21 10:38:54 -05:00
|
|
|
import { pageClassOn } from '../scripts/clientUtils';
|
2020-08-02 17:28:25 +09:00
|
|
|
|
2020-11-17 20:47:08 -05:00
|
|
|
// Set the default theme when loading
|
2020-09-26 21:48:22 +03:00
|
|
|
skinManager.setTheme(userSettings.theme())
|
2020-10-31 11:42:58 +03:00
|
|
|
/* 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-08-09 13:24:16 +02:00
|
|
|
|
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', () => {
|
2020-08-02 17:28:25 +09:00
|
|
|
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());
|
|
|
|
}
|
|
|
|
});
|