Skip to content

Commit

Permalink
fix: let recent replies respect oldest/newest sort settings
Browse files Browse the repository at this point in the history
  • Loading branch information
psychobunny committed Apr 11, 2021
1 parent 0f249aa commit 60eed8d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion public/src/client/topic/replies.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ define('forum/topic/replies', ['navigator', 'components', 'forum/topic/posts'],
app.parseAndTranslate('topic', 'posts', data, function (html) {
var replies = $('[component="post"][data-pid="' + post.toPid + '"] [component="post/replies"]').first();
if (replies.length) {
replies.append(html);
if (config.topicPostSort === 'newest_to_oldest') {
replies.prepend(html);
} else {
replies.append(html);
}
posts.onNewPostsAddedToDom(html);
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/socket.io/posts.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ SocketPosts.getReplies = async function (socket, pid) {
if (!utils.isNumber(pid)) {
throw new Error('[[error:invalid-data]]');
}

const pids = await posts.getPidsFromSet(`pid:${pid}:replies`, 0, -1, false);
const { topicPostSort } = await user.getSettings(socket.uid);
const pids = await posts.getPidsFromSet(`pid:${pid}:replies`, 0, -1, topicPostSort === 'newest_to_oldest');

let [postData, postPrivileges] = await Promise.all([
posts.getPostsByPids(pids, socket.uid),
Expand Down

0 comments on commit 60eed8d

Please sign in to comment.