mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-11-03 20:45:58 +01:00 
			
		
		
		
	fixed category sockets
This commit is contained in:
		@@ -133,7 +133,11 @@ define(['composer'], function(composer) {
 | 
				
			|||||||
			cid: cid,
 | 
								cid: cid,
 | 
				
			||||||
			after: $('#topics-container').children('.category-item').length
 | 
								after: $('#topics-container').children('.category-item').length
 | 
				
			||||||
		}, function (err, data) {
 | 
							}, function (err, data) {
 | 
				
			||||||
			if (!err && data.topics.length) {
 | 
								if(err) {
 | 
				
			||||||
 | 
									return app.alertError(err.message);
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (data && data.topics.length) {
 | 
				
			||||||
				Category.onTopicsLoaded(data.topics);
 | 
									Category.onTopicsLoaded(data.topics);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			loadingMoreTopics = false;
 | 
								loadingMoreTopics = false;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -124,9 +124,11 @@ var db = require('./database.js'),
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	Categories.getCategoryTopics = function(cid, start, stop, uid, callback) {
 | 
						Categories.getCategoryTopics = function(cid, start, stop, uid, callback) {
 | 
				
			||||||
		Categories.getTopicIds(cid, start, stop, function(err, tids) {
 | 
							Categories.getTopicIds(cid, start, stop, function(err, tids) {
 | 
				
			||||||
			topics.getTopicsByTids(tids, cid, uid, function(err, topicsData) {
 | 
								if(err) {
 | 
				
			||||||
				callback(err, topicsData);
 | 
									return callback(err);
 | 
				
			||||||
			});
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								topics.getTopicsByTids(tids, cid, uid, callback);
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -11,11 +11,15 @@ SocketCategories.get = function(socket, data, callback) {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SocketCategories.loadMore = function(socket, data, callback) {
 | 
					SocketCategories.loadMore = function(socket, data, callback) {
 | 
				
			||||||
 | 
						if(!data) {
 | 
				
			||||||
 | 
							return callback(new Error('invalid data'));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var start = data.after,
 | 
						var start = data.after,
 | 
				
			||||||
		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(err, topics) {
 | 
				
			||||||
		callback(null, {
 | 
							callback(err, {
 | 
				
			||||||
			topics: topics
 | 
								topics: topics
 | 
				
			||||||
		});
 | 
							});
 | 
				
			||||||
	});
 | 
						});
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,7 +44,7 @@ describe('Categories', function() {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	describe('.getCategoryTopics', function() {
 | 
						describe('.getCategoryTopics', function() {
 | 
				
			||||||
		it('should return a list of topics', function(done) {
 | 
							it('should return a list of topics', function(done) {
 | 
				
			||||||
			Categories.getCategoryTopics(categoryObj.cid, 0, 10, 0, function(topics) {
 | 
								Categories.getCategoryTopics(categoryObj.cid, 0, 10, 0, function(err, topics) {
 | 
				
			||||||
				assert(Array.isArray(topics));
 | 
									assert(Array.isArray(topics));
 | 
				
			||||||
				assert(topics.every(function(topic) {
 | 
									assert(topics.every(function(topic) {
 | 
				
			||||||
					return topic instanceof Object;
 | 
										return topic instanceof Object;
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user