Merge branch 'socketAL-fix' of https://github.com/designcreateplay/NodeBB into socketAL-fix

v1.18.x
Baris Soner Usakli 11 years ago
commit ced37044ca

@ -132,16 +132,16 @@ define(['composer'], function(composer) {
socket.emit('categories.loadMore', { socket.emit('categories.loadMore', {
cid: cid, cid: cid,
after: $('#topics-container').children('.category-item').length after: $('#topics-container').children('.category-item').length
}, function (data) { }, function (err, data) {
if (data.topics.length) { if (!err && data.topics.length) {
Category.onTopicsLoaded(data.topics); Category.onTopicsLoaded(data.topics);
} }
loadingMoreTopics = false; loadingMoreTopics = false;
}); });
} }
function renderRecentReplies(posts) { function renderRecentReplies(err, posts) {
if (!posts || posts.length === 0) { if (err || !posts || posts.length === 0) {
return; return;
} }

@ -92,7 +92,7 @@ define(['composer'], function(composer) {
var loadingEl = document.getElementById('categories-loading'); var loadingEl = document.getElementById('categories-loading');
if (loadingEl) { if (loadingEl) {
socket.emit('categories.get', function(data) { socket.emit('categories.get', function(err, data) {
// Render categories // Render categories
var categoriesFrag = document.createDocumentFragment(), var categoriesFrag = document.createDocumentFragment(),
categoryEl = document.createElement('li'), categoryEl = document.createElement('li'),

@ -3,17 +3,11 @@ var categories = require('../categories'),
SocketCategories = {}; SocketCategories = {};
SocketCategories.getRecentReplies = function(socket, tid, callback) { SocketCategories.getRecentReplies = function(socket, tid, callback) {
categories.getRecentReplies(tid, socket.uid, 4, function(err, replies) { categories.getRecentReplies(tid, socket.uid, 4, callback);
callback(replies);
});
}; };
SocketCategories.get = function(socket, data, callback) { SocketCategories.get = function(socket, data, callback) {
categories.getAllCategories(0, function(err, categories) { categories.getAllCategories(0, callback);
if(callback) {
callback(categories);
}
});
}; };
SocketCategories.loadMore = function(socket, data, callback) { SocketCategories.loadMore = function(socket, data, callback) {
@ -21,7 +15,7 @@ SocketCategories.loadMore = function(socket, data, callback) {
end = start + 9; end = start + 9;
categories.getCategoryTopics(data.cid, start, end, socket.uid, function(topics) { categories.getCategoryTopics(data.cid, start, end, socket.uid, function(topics) {
callback({ callback(null, {
topics: topics topics: topics
}); });
}); });

@ -134,7 +134,7 @@ Sockets.init = function() {
socket.on('*', function(payload, callback) { socket.on('*', function(payload, callback) {
function callMethod(method) { function callMethod(method) {
method.call(null, socket, payload.args.length ? payload.args[0] : null, function(err, result) { method.call(null, socket, payload.args.length ? payload.args[0] : null, function(err, result) {
if(callback) { if (callback) {
callback(err?{message:err.message}:null, result); callback(err?{message:err.message}:null, result);
} }
}); });

Loading…
Cancel
Save