From f62bc3e535b4af7b0a85487b2d76c1dc8174cf87 Mon Sep 17 00:00:00 2001 From: saimeunt Date: Tue, 31 Mar 2015 20:11:06 +0200 Subject: [PATCH] Unify posts hooks --- collections/posts.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/collections/posts.js b/collections/posts.js index 82cc948f6..00e5c7220 100644 --- a/collections/posts.js +++ b/collections/posts.js @@ -364,9 +364,9 @@ submitPost = function (post) { if (Meteor.isServer) { Meteor.defer(function () { // use defer to avoid holding up client // run all post submit server callbacks on post object successively - post = postAfterSubmitMethodCallbacks.reduce(function(result, currentFunction) { - return currentFunction(result); - }, post); + postAfterSubmitMethodCallbacks.forEach(function(currentFunction) { + currentFunction(post); + }); }); } @@ -492,10 +492,14 @@ Meteor.methods({ // ------------------------------ Callbacks ------------------------------ // - // run all post after edit method callbacks successively - postAfterEditMethodCallbacks.forEach(function(currentFunction) { - currentFunction(modifier, postId); - }); + if (Meteor.isServer) { + Meteor.defer(function () { // use defer to avoid holding up client + // run all post after edit method callbacks successively + postAfterEditMethodCallbacks.forEach(function(currentFunction) { + currentFunction(modifier, post); + }); + }); + } // ------------------------------ After Update ------------------------------ //