Skip to content

Node.js based forum software built for the modern web

closes #1022

Baris Soner Usakli8feac114c37b
diff --git a/src/threadTools.js b/src/threadTools.js
index b9fde04bc5..66269a9133 100644
--- a/src/threadTools.js
+++ b/src/threadTools.js
@@ -65,8 +65,6 @@ var winston = require('winston'),
return callback(err);
}
- db.decrObjectField('global', 'topicCount');
-
ThreadTools.lock(tid);
Plugins.fireHook('action:topic.delete', tid);
@@ -101,10 +99,10 @@ var winston = require('winston'),
return callback(err);
}
- db.incrObjectField('global', 'topicCount');
-
ThreadTools.unlock(tid);
+ Plugins.fireHook('action:topic.restore', tid);
+
events.logTopicRestore(uid, tid);
websockets.emitTopicPostStats();
@@ -113,8 +111,6 @@ var winston = require('winston'),
tid: tid
});
- Plugins.fireHook('action:topic.restore', tid);
-
callback(null, {
tid:tid
});
@@ -134,7 +130,7 @@ var winston = require('winston'),
tid: tid
});
}
- }
+ };
ThreadTools.unlock = function(tid, uid, callback) {
topics.setTopicField(tid, 'locked', 0);
diff --git a/src/topics.js b/src/topics.js
index ca7c134831..5c2690c10a 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -1154,6 +1154,16 @@ var async = require('async'),
});
}
+ Topics.updateTopicCount = function(callback) {
+ db.sortedSetCard('topics:recent', function(err, count) {
+ if(err) {
+ return callback(err);
+ }
+
+ db.setObjectField('global', count, callback);
+ });
+ };
+
Topics.delete = function(tid, callback) {
async.parallel([
function(next) {
@@ -1176,7 +1186,13 @@ var async = require('async'),
db.incrObjectFieldBy('category:' + cid, 'topic_count', -1, next);
});
}
- ], callback);
+ ], function(err) {
+ if (err) {
+ return callback(err);
+ }
+
+ Topics.updateTopicCount(callback);
+ });
};
Topics.restore = function(tid, callback) {
@@ -1206,7 +1222,13 @@ var async = require('async'),
db.incrObjectFieldBy('category:' + cid, 'topic_count', 1, next);
});
}
- ], callback);
+ ], function(err) {
+ if (err) {
+ return callback(err);
+ }
+
+ Topics.updateTopicCount(callback);
+ });
});
};
}(exports));