When the data change, It takes ages!! 10 sec min. Thats far too long.
Template.App_dashboard.onCreated(function() {
const userId = Meteor.userId();
this.step = new ReactiveDict();
this.autorun(() => {
this.subscribe("company");
const companyExists = Company.findOne({userId: userId});
const showLogoImageUploadForm = Company.findOne({userId: userId, showLogoImageUploadForm: true});
const instance = Template.instance();
if (companyExists && showLogoImageUploadForm) {
this.step.set('upload',true);
this.step.set('company',false);
}
if (!companyExists) {
this.step.set('company',true);
this.step.set('upload',false);
}
});
});
Template.App_dashboard.helpers({
step(step) {
const instance = Template.instance();
console.log('step ' + instance.step.get(step));
return instance.step.get(step);
}
});
<template name="App_dashboard">
<div class="navbar-fixed">
<nav>
<div class="nav-wrapper">
<a href="/" class="brand-logo"><img class="responsive-img" src="/img/qpona-logo-full-text-right.svg"></a>
<ul class="right hide-on-med-and-down">
<li><a href="sass.html">Sass</a></li>
<li><a href="badges.html">Components</a></li>
</ul>
</div>
</nav>
</div>
<div class="page">
{{#if step 'company'}}
{{> company}}
{{/if}}
{{#if step 'upload'}}
{{> uploads}}
{{/if}}
</div>
</template>