fixed categories.js socket callbacks

v1.18.x
Julian Lam 11 years ago
parent 8041bee9fd
commit cbb630fd6b

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

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

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

Loading…
Cancel
Save