diff --git a/hourglass/client/main/main.js b/hourglass/client/main/main.js index d97ad46..a546dfe 100644 --- a/hourglass/client/main/main.js +++ b/hourglass/client/main/main.js @@ -4,11 +4,6 @@ import { import './main.html'; -Meteor.subscribe('schools'); -Meteor.subscribe('classes'); -Meteor.subscribe('work'); -Meteor.subscribe('users'); - var openValues = { "menu": "-25%", "options": "-20%" @@ -178,9 +173,11 @@ Template.main.helpers({ return "width:"+w.toString()+"px;height:"+h.toString()+"px;margin-left:"+-0.5*w.toString()+"px;margin-top:"+-0.5*h.toString()+"px"; }, work(value) { + if(Session.get("currentWork") === null) return; return Session.get("currentReadableWork")[value]; }, workType() { + if(Session.get("currentWork") === null) return; type = Session.get("currentWork").type; if(type.includes("edit")) { return; diff --git a/hourglass/client/profile/profile.js b/hourglass/client/profile/profile.js index 78c4f40..b3e62ac 100644 --- a/hourglass/client/profile/profile.js +++ b/hourglass/client/profile/profile.js @@ -195,6 +195,7 @@ Template.profile.helpers({ return Session.get("confirmText"); }, selectedClass(val) { + if(Session.get("selectedClass") === null) return; var usertype = ["moderators","banned"]; var attribute = Session.get("selectClassId"); var array = classes.findOne({_id:attribute}); diff --git a/hourglass/lib/router.js b/hourglass/lib/router.js index b10d61a..0001e75 100644 --- a/hourglass/lib/router.js +++ b/hourglass/lib/router.js @@ -1,7 +1,17 @@ -Router.route('/', function() { - if (!Meteor.userId()) { - this.redirect('/login'); - } else { +Router.route('/', { + waitOn: function() { + if (!Meteor.userId()) { + this.redirect('/login'); + } else { + return [ + Meteor.subscribe('classes',this.params._id), + Meteor.subscribe('schools',this.params._id), + Meteor.subscribe('work',this.params._id), + Meteor.subscribe('users',this.params._id) + ]; + } + }, + action: function() { this.render("main"); } }); @@ -16,10 +26,20 @@ Router.route('/login', function() { } }); -Router.route('/profile', function() { - if (!Meteor.userId()) { - this.redirect("/login"); - } else { +Router.route('/profile', { + waitOn: function() { + if (!Meteor.userId()) { + this.redirect('/login'); + } else { + return [ + Meteor.subscribe('classes',this.params._id), + Meteor.subscribe('schools',this.params._id), + Meteor.subscribe('work',this.params._id), + Meteor.subscribe('users',this.params._id) + ]; + } + }, + action: function() { this.render("profile"); } });