mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-26 15:58:50 +00:00
40 lines
No EOL
1.2 KiB
JavaScript
40 lines
No EOL
1.2 KiB
JavaScript
import { UserConfig } from "../imports/api/userConfig";
|
|
|
|
Template.MainLayout.onCreated(function() {
|
|
this.subscribe("UserConfigPrefs");
|
|
});
|
|
|
|
Template.MainLayout.onRendered(function() {
|
|
this.autorun(() => {
|
|
let myId = Meteor.userId();
|
|
const getConfig = async() => {
|
|
let myprefs = await UserConfig.findOneAsync({ user: myId });
|
|
try {
|
|
if (!myprefs) {
|
|
// console.log("User Prefs appear undefined.");
|
|
} else {
|
|
if (myprefs.darkMode == "light") {
|
|
// console.log("Found theme as light");
|
|
Session.set("myTheme", "light");
|
|
document.documentElement.setAttribute('theme', "light");
|
|
} else {
|
|
// console.log("Found theme as dark");
|
|
Session.set("myTheme", "dark");
|
|
document.documentElement.setAttribute('theme', "dark");
|
|
}
|
|
}
|
|
} catch(error) {
|
|
console.log(" ERROR getting user preferences: " + error);
|
|
}
|
|
}
|
|
getConfig();
|
|
});
|
|
});
|
|
|
|
Template.MainLayout.helpers({
|
|
|
|
});
|
|
|
|
Template.MainLayout.events({
|
|
|
|
}); |