From d272a87c8a30b5c21c31d135b6846b564da998ca Mon Sep 17 00:00:00 2001 From: barisusakli Date: Mon, 5 May 2014 09:33:47 -0400 Subject: [PATCH] cleanup toggleFollow --- src/threadTools.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/threadTools.js b/src/threadTools.js index 0ffbea46d4..4ab1a165f4 100644 --- a/src/threadTools.js +++ b/src/threadTools.js @@ -210,17 +210,13 @@ var winston = require('winston'), ThreadTools.toggleFollow = function(tid, uid, callback) { topics.isFollowing(tid, uid, function(err, following) { - if(err) { + if (err) { return callback(err); } - db[following ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err, success) { - if (callback) { - if(err) { - return callback(err); - } - - callback(null, !following); + db[following ? 'setRemove' : 'setAdd']('tid:' + tid + ':followers', uid, function(err) { + if (typeof callback === 'function') { + callback(err, !following); } }); });