From 60eed8d89fa33dfece719cb341402bd9fd96ea45 Mon Sep 17 00:00:00 2001 From: psychobunny Date: Sun, 11 Apr 2021 19:53:40 -0400 Subject: [PATCH] fix: let recent replies respect oldest/newest sort settings --- public/src/client/topic/replies.js | 6 +++++- src/socket.io/posts.js | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/public/src/client/topic/replies.js b/public/src/client/topic/replies.js index bbdde3be62..57d63f4672 100644 --- a/public/src/client/topic/replies.js +++ b/public/src/client/topic/replies.js @@ -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); } }); diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js index 82d45d06b8..2af48a17c6 100644 --- a/src/socket.io/posts.js +++ b/src/socket.io/posts.js @@ -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),