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({ });