Skip to content

Node.js based forum software built for the modern web

closes #37, used the sorted set and updated it when a new post is made to a topic

Baris Soner Usakli7d49294595b3
diff --git a/public/src/forum/register.js b/public/src/forum/register.js
index 755a55fba2..5c58edc28a 100644
--- a/public/src/forum/register.js
+++ b/public/src/forum/register.js
@@ -64,7 +64,7 @@
socket.on('user.email.exists', function(data) {
emailexists = data.exists;
emailvalid = isEmailValid(email.value);
- console.log('derp');
+
if (data.exists === true) {
email_notify.innerHTML = 'Email Address exists';
email_notify.className = 'label label-important';
diff --git a/src/categories.js b/src/categories.js
index 0b2082d88d..135f6e2a16 100644
--- a/src/categories.js
+++ b/src/categories.js
@@ -80,7 +80,7 @@ var RDB = require('./redis.js'),
// not the permanent location for this function
Categories.getLatestTopics = function(current_user, start, end, callback) {
- RDB.zrange('topics:recent', 0, -1, function(err, tids) {
+ RDB.zrevrange('topics:recent', 0, -1, function(err, tids) {
var latestTopics = {
'category_name' : 'Recent',
'show_sidebar' : 'hidden',
@@ -206,12 +206,11 @@ var RDB = require('./redis.js'),
retrieved_topics = retrieved_topics.sort(function(a, b) {
if (a.pinned !== b.pinned) return b.pinned - a.pinned;
else {
- // Sort by datetime descending
- return b.timestamp - a.timestamp;
+ // assume equal, tids are already sorted due to RDB.zadd(schema.topics().recent, Date.now(), tid);
+ return 0;
}
});
-
callback(retrieved_topics);
});
});
diff --git a/src/posts.js b/src/posts.js
index 4d59cb34bd..e0c209dfd8 100644
--- a/src/posts.js
+++ b/src/posts.js
@@ -1,5 +1,6 @@
var RDB = require('./redis.js'),
utils = require('./../public/src/utils.js'),
+ schema = require('./schema.js'),
marked = require('marked'),
user = require('./user.js'),
topics = require('./topics.js'),
@@ -257,6 +258,7 @@ marked.setOptions({
RDB.set('pid:' + pid + ':tid', tid);
RDB.incr('tid:' + tid + ':postcount');
+ RDB.zadd(schema.topics().recent, Date.now(), tid);
user.getUserFields(uid, ['username'], function(data) { // todo parallel
//add active users to this category