Move global subscription to template subscription so that subscription

will stop when template is unused. It's very important for efficiency
espacially with large number of users. Thanks to mfshiu !
This commit is contained in:
Lauri Ojansivu 2017-12-02 22:00:42 +02:00
parent fa281e3f5f
commit 233554a3d6
5 changed files with 14 additions and 11 deletions

View file

@ -23,8 +23,12 @@ BlazeComponent.extendComponent({
this.parentComponent().showOverlay.set(true);
this.parentComponent().mouseHasEnterCardDetails = false;
this.calculateNextPeak();
Meteor.subscribe('unsaved-edits');
},
isWatching() {
const card = this.currentData();
return card.findWatcher(Meteor.userId());

View file

@ -1,8 +1,3 @@
Meteor.subscribe('setting');
Meteor.subscribe('mailServer');
Meteor.subscribe('accountSettings');
Meteor.subscribe('announcements');
BlazeComponent.extendComponent({
onCreated() {
this.error = new ReactiveVar('');
@ -11,6 +6,11 @@ BlazeComponent.extendComponent({
this.emailSetting = new ReactiveVar(false);
this.accountSetting = new ReactiveVar(false);
this.announcementSetting = new ReactiveVar(false);
Meteor.subscribe('setting');
Meteor.subscribe('mailServer');
Meteor.subscribe('accountSettings');
Meteor.subscribe('announcements');
},
setError(error) {

View file

@ -1,5 +1,3 @@
Meteor.subscribe('my-avatars');
Template.userAvatar.helpers({
userData() {
// We need to handle a special case for the search results provided by the
@ -54,6 +52,8 @@ Template.userAvatarInitials.helpers({
BlazeComponent.extendComponent({
onCreated() {
this.error = new ReactiveVar('');
Meteor.subscribe('my-avatars');
},
avatarUrlOptions() {