fix: infinite scroll for posts

This commit is contained in:
Julian Lam
2024-01-16 11:42:59 -05:00
parent 5ac0276530
commit 8cd3ff1ab4
2 changed files with 4 additions and 2 deletions

View File

@@ -256,7 +256,7 @@ define('forum/topic/posts', [
const after = parseInt(afterEl.attr('data-index'), 10) || 0;
const tid = ajaxify.data.tid;
if (!utils.isNumber(tid) || !utils.isNumber(after) || (direction < 0 && components.get('post', 'index', 0).length)) {
if (!utils.isNumber(after) || (direction < 0 && components.get('post', 'index', 0).length)) {
return;
}

View File

@@ -5,6 +5,7 @@ const privileges = require('../../privileges');
const meta = require('../../meta');
const utils = require('../../utils');
const social = require('../../social');
const activitypub = require('../../activitypub');
module.exports = function (SocketTopics) {
SocketTopics.loadMore = async function (socket, data) {
@@ -21,7 +22,8 @@ module.exports = function (SocketTopics) {
throw new Error('[[error:no-privileges]]');
}
const set = data.topicPostSort === 'most_votes' ? `tid:${data.tid}:posts:votes` : `tid:${data.tid}:posts`;
const setPrefix = activitypub.helpers.isUri(data.tid) ? 'tidRemote' : 'tid';
const set = data.topicPostSort === 'most_votes' ? `${setPrefix}:${data.tid}:posts:votes` : `${setPrefix}:${data.tid}:posts`;
const reverse = data.topicPostSort === 'newest_to_oldest' || data.topicPostSort === 'most_votes';
let start = Math.max(0, parseInt(data.after, 10));