Skip to content

Commit

Permalink
The startRequest function should only run when the page of the router…
Browse files Browse the repository at this point in the history
… changes.
  • Loading branch information
tmeasday committed Nov 21, 2012
1 parent 720373f commit 7a59ccf
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
45 changes: 23 additions & 22 deletions client/lib/router.js
Expand Up @@ -126,27 +126,6 @@


Meteor.Router.filters({
startRequest: function(page){
// runs at every new page change
console.log('------ Request start --------');
// openedComments is an Array that tracks which comments
// have been expanded by the user, to make sure they stay expanded
Session.set("openedComments", null);

// currentScroll stores the position of the user in the page
Session.set('currentScroll', null);

document.title = getSetting("title");

// set all errors who have already been seen to not show anymore
clearSeenErrors();

// log this request with mixpanel, etc
instrumentRequest();

return page;
},

requireLogin: function(page) {
if (Meteor.loggingIn()) {
return 'loading';
Expand Down Expand Up @@ -234,7 +213,6 @@
}
});
//
Meteor.Router.filter('startRequest'); // all
Meteor.Router.filter('requireProfile');
Meteor.Router.filter('awaitSubscription', {
only: ['posts_top', 'posts_new', 'posts_pending', 'posts_digest']
Expand All @@ -249,4 +227,27 @@
Meteor.Router.filter('canEdit', {only: ['post_edit', 'comment_edit']});
Meteor.Router.filter('requirePost', {only: ['post_page', 'post_edit']});
Meteor.Router.filter('isAdmin', {only: ['posts_pending', 'users', 'settings', 'categories', 'admin']});

Meteor.startup(function() {
Meteor.autorun(function() {
// grab the current page from the router, so this re-runs every time it changes
Meteor.Router.page();
console.log('------ Request start --------');

// openedComments is an Array that tracks which comments
// have been expanded by the user, to make sure they stay expanded
Session.set("openedComments", null);

// currentScroll stores the position of the user in the page
Session.set('currentScroll', null);

document.title = getSetting("title");

// set all errors who have already been seen to not show anymore
clearSeenErrors();

// log this request with mixpanel, etc
instrumentRequest();
});
});
}());
4 changes: 2 additions & 2 deletions smart.lock
Expand Up @@ -12,8 +12,8 @@
"packages": {
"router": {
"git": "https://github.com/tmeasday/meteor-router.git",
"tag": "v0.2.5",
"commit": "e6718dbccfbbf3f964464053a310ccbcdb766ece"
"tag": "v0.2.6",
"commit": "a1866908a9fb6d287bb877c6583cee93f89e378e"
},
"moment": {
"git": "https://github.com/possibilities/meteor-moment.git",
Expand Down

0 comments on commit 7a59ccf

Please sign in to comment.