Skip to content

Node.js based forum software built for the modern web

test

barisusaklic63d5f4b7a6f
diff --git a/src/groups.js b/src/groups.js
index 3f1ba0ddf7..25c8ff1bdc 100644
--- a/src/groups.js
+++ b/src/groups.js
@@ -953,11 +953,7 @@ var async = require('async'),
var memberOf = [];
isMembers.forEach(function(isMember, index) {
if (isMember) {
- if (uids.length > 1) {
- memberOf.push(util._extend({}, groupData[index]));
- } else {
- memberOf.push(groupData[index]);
- }
+ memberOf.push(groupData[index]);
}
});
diff --git a/src/posts/user.js b/src/posts/user.js
index 494b1dbc6f..8d64aeb621 100644
--- a/src/posts/user.js
+++ b/src/posts/user.js
@@ -33,10 +33,18 @@ module.exports = function(Posts) {
var userData = results.userData;
userData.forEach(function(userData, i) {
- userData.groups = results.groups[i];
-
- userData.groups.forEach(function(group) {
- group.selected = group.name === results.userSettings[i].groupTitle;
+ userData.groups = [];
+
+ results.groups[i].forEach(function(group, index) {
+ userData.groups[index] = {
+ name: group.name,
+ slug: group.slug,
+ labelColor: group.labelColor,
+ icon: group.icon,
+ userTitle: group.userTitle,
+ userTitleEnabled: group.userTitleEnabled,
+ selected: group.name === results.userSettings[i].groupTitle
+ };
});
userData.status = user.getStatus(userData.status, results.online[i]);
});
diff --git a/src/topics.js b/src/topics.js
index 3c22bcf30c..6dd1a6361a 100644
--- a/src/topics.js
+++ b/src/topics.js
@@ -216,11 +216,14 @@ var async = require('async'),
}
async.parallel({
- mainPost: function(next) {
- getMainPosts([topicData.mainPid], uid, next);
- },
+ // mainPost: function(next) {
+ // getMainPosts([topicData.mainPid], uid, next);
+ // },
+ // posts: function(next) {
+ // Topics.getTopicPosts(tid, set, start, end, uid, reverse, next);
+ // },
posts: function(next) {
- Topics.getTopicPosts(tid, set, start, end, uid, reverse, next);
+ getMainPostAndReplies(topicData, set, uid, start, end, reverse, next);
},
category: async.apply(Topics.getCategoryData, tid),
threadTools: async.apply(plugins.fireHook, 'filter:topic.thread_tools', {topic: topicData, uid: uid, tools: []}),
@@ -231,7 +234,8 @@ var async = require('async'),
return callback(err);
}
- topicData.posts = Array.isArray(results.mainPost) && results.mainPost.length ? [results.mainPost[0]].concat(results.posts) : results.posts;
+ //topicData.posts = Array.isArray(results.mainPost) && results.mainPost.length ? [results.mainPost[0]].concat(results.posts) : results.posts;
+ topicData.posts = results.posts;
topicData.category = results.category;
topicData.thread_tools = results.threadTools.tools;
topicData.tags = results.tags;
@@ -249,6 +253,34 @@ var async = require('async'),
});
};
+ function getMainPostAndReplies(topic, set, uid, start, end, reverse, callback) {
+ async.waterfall([
+ function(next) {
+ posts.getPidsFromSet(set, start, end, reverse, next);
+ },
+ function(pids, next) {
+ if ((!Array.isArray(pids) || !pids.length) && !topic.mainPid) {
+ return callback(null, []);
+ }
+
+ if (topic.mainPid) {
+ pids.unshift(topic.mainPid);
+ }
+ posts.getPostsByPids(pids, uid, next);
+ },
+ function(posts, next) {
+ var indices = Topics.calculatePostIndices(start, end, topic.postcount, reverse);
+ posts.forEach(function(post, index) {
+ if (post) {
+ post.index = indices[index] - 1;
+ }
+ });
+
+ Topics.addPostData(posts, uid, callback);
+ }
+ ]);
+ }
+
Topics.getMainPost = function(tid, uid, callback) {
Topics.getMainPosts([tid], uid, function(err, mainPosts) {
callback(err, Array.isArray(mainPosts) && mainPosts.length ? mainPosts[0] : null);