Skip to content

Commit

Permalink
WIP: move away from global sessions, use controller state to handle i…
Browse files Browse the repository at this point in the history
…ncremental subs #6
  • Loading branch information
erasaur committed Apr 28, 2015
1 parent 239bca7 commit 137ba48
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/routes/admin.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
AdminController = RouteController.extend({
subscriptions: function () {
return Meteor.subscribe('flagsList', Session.get('itemsLimit'));
var limit = Meteor.isClient && this.state.get('itemsLimit') || 15;
return Meteor.subscribe('flagsList', limit);
},
onBeforeAction: function () {
if (!Meteor.userId() || !isAdmin(Meteor.user())) {
var userId = Meteor.userId();
if (!isAdminById(userId)) {
this.redirect('home');
}
this.next();
},
onRun: function () {
Session.set('itemsLimit', 1);
this.state.set('itemsLimit', 15);
this.next();
},
action: function () {
if (this.ready()) {
this.render();
this.render('nav', { to: 'nav' });
this.render();
}
}
});
Expand Down

0 comments on commit 137ba48

Please sign in to comment.