diff --git a/client/templates/post_edit.html b/client/templates/post_edit.html index 2cd91d34d..d4c1a93c2 100644 --- a/client/templates/post_edit.html +++ b/client/templates/post_edit.html @@ -2,20 +2,18 @@
{{#with post}}
- {{#constant}} -
- -
-
-
- -
-
-
- -
-
- {{/constant}} +
+ +
+
+
+ +
+
+
+ +
+
Delete Post diff --git a/client/templates/post_edit.js b/client/templates/post_edit.js index 6605ff715..ffa03f232 100644 --- a/client/templates/post_edit.js +++ b/client/templates/post_edit.js @@ -2,7 +2,28 @@ Template.post_edit.helpers({ post: function(){ - return Posts.findOne(Session.get('selectedPostId')); + // The idea here is to isolate the call to findOne() so that it stops + // being reactive once data is found. The reason being that server scoring + // updates will 'change' the post, and meteor will overwrite the user's + // input, even if preserve is set. + // Kind of like {{#constant}}, except it waits for data. + // + // XXX: either figure out a different approach, or factor this out and + // use everywhere. + var outerContext = Meteor.deps.Context.current; + var innerContext = new Meteor.deps.Context; + var post; + + innerContext.onInvalidate(function() { + // we don't need to send the invalidate through anymore if post is set + post || outerContext.invalidate(); + }); + + innerContext.run(function() { + post = Posts.findOne(Session.get('selectedPostId')); + }) + + return post; } });