fix topic move

v1.18.x
barisusakli 11 years ago
parent 10b30e303b
commit 84d0e64361

@ -43,7 +43,7 @@ define('forum/topic/move', function() {
renderCategories(categories); renderCategories(categories);
modal.find('.category-list').on('click', 'li[data-cid]', function(e) { modal.on('click', '.category-list li[data-cid]', function(e) {
selectCategory($(this)); selectCategory($(this));
}); });

@ -13,14 +13,18 @@ module.exports = function(db, module) {
value: value value: value
}; };
db.collection('objects').update({_key: key, value: value}, {$set: data}, {upsert:true, w: 1}, callback); db.collection('objects').update({_key: key, value: value}, {$set: data}, {upsert:true, w: 1}, function(err) {
callback(err);
});
}; };
module.sortedSetRemove = function(key, value, callback) { module.sortedSetRemove = function(key, value, callback) {
callback = callback || helpers.noop; callback = callback || helpers.noop;
value = helpers.valueToString(value); value = helpers.valueToString(value);
db.collection('objects').remove({_key: key, value: value}, callback); db.collection('objects').remove({_key: key, value: value}, function(err) {
callback(err);
});
}; };
module.sortedSetsRemove = function(keys, value, callback) { module.sortedSetsRemove = function(keys, value, callback) {

@ -3,11 +3,16 @@
module.exports = function(redisClient, module) { module.exports = function(redisClient, module) {
module.sortedSetAdd = function(key, score, value, callback) { module.sortedSetAdd = function(key, score, value, callback) {
callback = callback || function() {}; callback = callback || function() {};
redisClient.zadd(key, score, value, callback); redisClient.zadd(key, score, value, function(err) {
callback(err);
});
}; };
module.sortedSetRemove = function(key, value, callback) { module.sortedSetRemove = function(key, value, callback) {
redisClient.zrem(key, value, callback); callback = callback || function() {};
redisClient.zrem(key, value, function(err) {
callback(err);
});
}; };
module.sortedSetsRemove = function(keys, value, callback) { module.sortedSetsRemove = function(keys, value, callback) {

@ -85,7 +85,7 @@ Sockets.init = function(server) {
if (uid) { if (uid) {
db.sortedSetAdd('users:online', Date.now(), uid, function(err, data) { db.sortedSetAdd('users:online', Date.now(), uid, function(err) {
socket.join('uid_' + uid); socket.join('uid_' + uid);
async.parallel({ async.parallel({

@ -189,12 +189,12 @@ var winston = require('winston'),
topic = topicData; topic = topicData;
db.sortedSetRemove('categories:' + topicData.cid + ':tid', tid, next); db.sortedSetRemove('categories:' + topicData.cid + ':tid', tid, next);
}, },
function(result, next) { function(next) {
var timestamp = parseInt(topic.pinned, 10) ? Math.pow(2, 53) : topic.lastposttime; var timestamp = parseInt(topic.pinned, 10) ? Math.pow(2, 53) : topic.lastposttime;
db.sortedSetAdd('categories:' + cid + ':tid', timestamp, tid, next); db.sortedSetAdd('categories:' + cid + ':tid', timestamp, tid, next);
} }
], function(err, result) { ], function(err) {
if(err) { if (err) {
return callback(err); return callback(err);
} }
var oldCid = topic.cid; var oldCid = topic.cid;

@ -271,14 +271,14 @@ describe('Test database', function() {
it('should not throw err', function(done) { it('should not throw err', function(done) {
function sortedSetAdd(callback) { function sortedSetAdd(callback) {
db.sortedSetAdd('sortedSet3', 12, 5, function(err, data) { db.sortedSetAdd('sortedSet3', 12, 5, function(err) {
callback(err, {'sortedSetAdd': data}); callback(err);
}); });
} }
function sortedSetRemove(callback) { function sortedSetRemove(callback) {
db.sortedSetRemove('sortedSet3', 12, function(err, data) { db.sortedSetRemove('sortedSet3', 12, function(err, data) {
callback(err, {'sortedSetRemove': data}); callback(err);
}); });
} }

Loading…
Cancel
Save