mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 11:05:54 +01:00 
			
		
		
		
	show topics on home instead of replies
no template changes, instead of showing the latest x posts under categories, we are now showing the latest x posts of the latest x topics.
This commit is contained in:
		| @@ -10,7 +10,7 @@ var async = require('async'), | ||||
|  | ||||
| module.exports = function(Categories) { | ||||
| 	Categories.getRecentReplies = function(cid, uid, count, callback) { | ||||
| 		if(!parseInt(count, 10)) { | ||||
| 		if (!parseInt(count, 10)) { | ||||
| 			return callback(null, []); | ||||
| 		} | ||||
|  | ||||
| @@ -23,6 +23,26 @@ module.exports = function(Categories) { | ||||
| 		}); | ||||
| 	}; | ||||
|  | ||||
| 	Categories.getRecentTopicReplies = function(cid, uid, count, callback) { | ||||
| 		if (!parseInt(count, 10)) { | ||||
| 			return callback(null, []); | ||||
| 		} | ||||
|  | ||||
| 		db.getSortedSetRevRange('categories:' + cid + ':tid', 0, count - 1, function(err, tids) { | ||||
| 			if (err || !tids || !tids.length) { | ||||
| 				return callback(err, []); | ||||
| 			} | ||||
|  | ||||
| 			async.map(tids, topics.getLatestUndeletedPid, function(err, pids) { | ||||
| 				pids = pids.filter(function(pid) { | ||||
| 					return !!pid; | ||||
| 				}); | ||||
|  | ||||
| 				posts.getPostSummaryByPids(pids, {stripTags: true}, callback); | ||||
| 			}); | ||||
| 		}); | ||||
| 	}; | ||||
|  | ||||
| 	Categories.moveRecentReplies = function(tid, oldCid, cid) { | ||||
| 		function movePost(postData, next) { | ||||
| 			async.parallel([ | ||||
|   | ||||
| @@ -70,7 +70,7 @@ Controllers.home = function(req, res, next) { | ||||
| 				} | ||||
|  | ||||
| 				function getRecentReplies(category, callback) { | ||||
| 					categories.getRecentReplies(category.cid, uid, parseInt(category.numRecentReplies, 10), function (err, posts) { | ||||
| 					categories.getRecentTopicReplies(category.cid, uid, parseInt(category.numRecentReplies, 10), function (err, posts) { | ||||
| 						if (err) { | ||||
| 							return callback(err); | ||||
| 						} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user