From 9cb20c3886cb1680f72ee9f3265d5754b6b12798 Mon Sep 17 00:00:00 2001 From: Baris Soner Usakli Date: Mon, 16 Dec 2013 19:12:26 -0500 Subject: [PATCH] added callback to api categories.get --- public/src/forum/topic.js | 5 ++--- src/websockets.js | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/public/src/forum/topic.js b/public/src/forum/topic.js index 3a47ce901c..824ef1cfb8 100644 --- a/public/src/forum/topic.js +++ b/public/src/forum/topic.js @@ -102,7 +102,7 @@ define(function() { var loadingEl = document.getElementById('categories-loading'); if (loadingEl) { - socket.once('api:categories.get', function(data) { + socket.emit('api:categories.get', function(data) { // Render categories var categoriesFrag = document.createDocumentFragment(), categoryEl = document.createElement('li'), @@ -172,7 +172,6 @@ define(function() { } }); }); - socket.emit('api:categories.get'); } }); } @@ -802,7 +801,7 @@ define(function() { pagination.parentNode.style.display = 'block'; progressBarContainer.css('display', ''); - + if (scrollTop < jQuery('.posts > .post-row:first-child').height() && Topic.postCount > 1) { localStorage.removeItem("topic:" + tid + ":bookmark"); pagination.innerHTML = '1 out of ' + Topic.postCount; diff --git a/src/websockets.js b/src/websockets.js index 4547f1d3b1..81a3bbe221 100644 --- a/src/websockets.js +++ b/src/websockets.js @@ -591,9 +591,9 @@ websockets.init = function(io) { threadTools.move(data.tid, data.cid, socket); }); - socket.on('api:categories.get', function() { + socket.on('api:categories.get', function(callback) { categories.getAllCategories(0, function(err, categories) { - socket.emit('api:categories.get', categories); + callback(categories); }); });