Permalink
Browse files

make sure the comment/post being edited is loaded before moving on

  • Loading branch information...
1 parent 14421ff commit ebaf483d4642dd216ad8621a5d737d82e94807ac @SachaG committed Jun 18, 2013
Showing with 25 additions and 12 deletions.
  1. +1 −1 .meteor/release
  2. +1 −1 client/helpers/analytics.js
  3. +12 −5 client/helpers/router.js
  4. +6 −2 client/main.js
  5. +2 −0 client/views/posts/post_page.js
  6. +3 −3 smart.lock
View
@@ -1 +1 @@
-0.6.0
+0.6.4
@@ -73,7 +73,7 @@ analyticsInit = function() {
analyticsRequest = function() {
// Google Analytics
- if ((googleAnalyticsId = getSetting("googleAnalyticsId"))){
+ if (googleAnalyticsId = getSetting("googleAnalyticsId") && window._gaq){
window._gaq.push(['_trackPageview', window.location.pathname]);
}
View
@@ -50,7 +50,6 @@
// on post page, we show the comment tree
Session.set('showChildComments',true);
-
return 'post_page';
};
@@ -190,20 +189,28 @@
canEdit: function(page) {
// make findOne() non reactive to avoid re-triggering the router every time the
// current comment or post object changes
+ // but make sure the comment/post is loaded before moving on
if (page === 'comment_edit') {
var item = Comments.findOne(Session.get('selectedCommentId'), {reactive: false});
+ if(!Session.get('singleCommentReady'))
+ return 'loading'
} else {
var item = Posts.findOne(Session.get('selectedPostId'), {reactive: false});
+ if(!Session.get('singlePostReady'))
+ return 'loading'
}
-
+
var error = canEdit(Meteor.user(), item, true);
- if (error === true)
+ if (error === true){
return page;
+
+ }
// a problem.. make sure the item has loaded and we have logged in
- if (! item || Meteor.loggingIn())
+ if (! item || Meteor.loggingIn()){
return 'loading';
-
+ }
+
// otherwise the error tells us what to show.
return error;
},
View
@@ -2,6 +2,7 @@
Session.set('initialLoad', true);
Session.set('currentDate', new Date());
Session.set('categorySlug', null);
+Session.set('singlePostReady', false);
// Settings
Meteor.subscribe('settings', function(){
@@ -32,7 +33,9 @@ if(Meteor.userId() != null){
// Single Post
Meteor.autorun(function() {
- Meteor.subscribe('singlePost', Session.get('selectedPostId'));
+ Meteor.subscribe('singlePost', Session.get('selectedPostId'), function(){
+ Session.set('singlePostReady', true);
+ });
});
// Digest
@@ -80,9 +83,10 @@ pendingPostsHandle = postListSubscription(selectPending, sortPosts('createdAt'),
// Collection depends on selectedPostId and selectedCommentId session variable
Session.set('selectedPostId', null);
+
Meteor.autosubscribe(function() {
var query = { $or : [ { post : Session.get('selectedPostId') } , { _id : Session.get('selectedCommentId') } ] };
Meteor.subscribe('comments', query, function() {
- Session.set('commentReady', true);
+ Session.set('singleCommentReady', true);
});
});
@@ -12,6 +12,8 @@ Template.post_page.helpers({
return canComment(Meteor.user());
},
canView: function(){
+ console.log('asdas')
+ console.log(canView(Meteor.user()))
return canView(Meteor.user());
}
});
View
@@ -2,7 +2,7 @@
"meteor": {
"git": "https://github.com/meteor/meteor.git",
"branch": "master",
- "commit": "1dfc7171f237a029cca74cbf25024acbf6ed5b75"
+ "commit": "9bb2b5447e845c4f483df5e9b42a2c1de5ab909b"
},
"dependencies": {
"basePackages": {
@@ -33,8 +33,8 @@
},
"paginated-subscription": {
"git": "https://github.com/tmeasday/meteor-paginated-subscription.git",
- "tag": "v0.1.1",
- "commit": "1ba670364ddac149f404158407b2afc89db42ce5"
+ "tag": "v0.1.2",
+ "commit": "35e0c6112df2b4cfeb60b559276a93cac5ee2dd6"
},
"crypto-md5": {
"git": "https://github.com/tmeasday/meteor-crypto-md5.git",

0 comments on commit ebaf483

Please sign in to comment.