mirror of
https://github.com/NodeBB/NodeBB.git
synced 2026-02-01 20:30:07 +01:00
replies/reply fix
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
"quote": "Quote",
|
||||
"reply": "Reply",
|
||||
"replies_to_this_post": "%1 Replies",
|
||||
"one_reply_to_this_post": "1 Reply",
|
||||
"last_reply_time": "Last reply",
|
||||
"reply-as-topic": "Reply as topic",
|
||||
"guest-login-reply": "Log in to reply",
|
||||
|
||||
@@ -89,8 +89,19 @@ define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts'],
|
||||
var timestamp = replyCount.find('.timeago').attr('title', post.timestampISO);
|
||||
|
||||
countEl.attr('data-replies', count);
|
||||
replyCount.toggleClass('hidden', !count);
|
||||
countEl.translateText('[[topic:replies_to_this_post, ' + count + ']]');
|
||||
replyCount.toggleClass('hidden', count <= 0);
|
||||
if (count > 1) {
|
||||
countEl.translateText('[[topic:replies_to_this_post, ' + count + ']]');
|
||||
} else {
|
||||
countEl.translateText('[[topic:one_reply_to_this_post]]');
|
||||
}
|
||||
|
||||
if (!avatars.find('[data-uid="' + post.uid + '"]').length && count < 7) {
|
||||
app.parseAndTranslate('topic', 'posts', { posts: [{ replies: { users: [post.user] } }] }, function (html) {
|
||||
avatars.prepend(html.find('[component="post/reply-count/avatars"] [component="user/picture"]'));
|
||||
});
|
||||
}
|
||||
|
||||
avatars.addClass('hasMore');
|
||||
|
||||
timestamp.data('timeago', null).timeago();
|
||||
|
||||
@@ -392,30 +392,36 @@ module.exports = function (Topics) {
|
||||
|
||||
function getPostReplies(pids, callerUid, callback) {
|
||||
async.map(pids, function (pid, next) {
|
||||
db.getSortedSetRange('pid:' + pid + ':replies', 0, -1, function (err, replyPids) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var replyPids;
|
||||
var uids = [];
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
db.getSortedSetRange('pid:' + pid + ':replies', 0, -1, next);
|
||||
},
|
||||
function (_replyPids, next) {
|
||||
replyPids = _replyPids;
|
||||
|
||||
var uids = [];
|
||||
var count = 0;
|
||||
|
||||
async.until(function () {
|
||||
return count === replyPids.length || uids.length === 6;
|
||||
}, function (next) {
|
||||
posts.getPostField(replyPids[count], 'uid', function (err, uid) {
|
||||
uid = parseInt(uid, 10);
|
||||
if (uids.indexOf(uid) === -1) {
|
||||
uids.push(uid);
|
||||
}
|
||||
count += 1;
|
||||
next(err);
|
||||
});
|
||||
}, function (err) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
}
|
||||
var count = 0;
|
||||
|
||||
async.until(function () {
|
||||
return count === replyPids.length || uids.length === 6;
|
||||
}, function (next) {
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
posts.getPostField(replyPids[count], 'uid', next);
|
||||
},
|
||||
function (uid, next) {
|
||||
uid = parseInt(uid, 10);
|
||||
if (uids.indexOf(uid) === -1) {
|
||||
uids.push(uid);
|
||||
}
|
||||
count += 1;
|
||||
next();
|
||||
},
|
||||
], next);
|
||||
}, next);
|
||||
},
|
||||
function (next) {
|
||||
async.parallel({
|
||||
users: function (next) {
|
||||
user.getUsersWithFields(uids, ['uid', 'username', 'userslug', 'picture'], callerUid, next);
|
||||
@@ -425,17 +431,19 @@ module.exports = function (Topics) {
|
||||
next(err, utils.toISOString(timestamp));
|
||||
});
|
||||
},
|
||||
}, function (err, replies) {
|
||||
if (replies.users.length > 5) {
|
||||
replies.users.shift();
|
||||
replies.hasMore = true;
|
||||
}
|
||||
}, next);
|
||||
},
|
||||
function (replies, next) {
|
||||
if (replies.users.length > 5) {
|
||||
replies.users.shift();
|
||||
replies.hasMore = true;
|
||||
}
|
||||
|
||||
replies.count = replyPids.length;
|
||||
next(err, replies);
|
||||
});
|
||||
});
|
||||
});
|
||||
replies.count = replyPids.length;
|
||||
replies.text = replies.count > 1 ? '[[topic:replies_to_this_post, ' + replies.count + ']]' : '[[topic:one_reply_to_this_post]]';
|
||||
next(null, replies);
|
||||
},
|
||||
], next);
|
||||
}, callback);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user