diff --git a/public/src/client/tag.js b/public/src/client/tag.js index a23690ba68..ce45a94aae 100644 --- a/public/src/client/tag.js +++ b/public/src/client/tag.js @@ -1,22 +1,12 @@ 'use strict'; - -define('forum/tag', ['topicList', 'forum/infinitescroll'], function (topicList, infinitescroll) { +define('forum/tag', ['topicList', 'forum/infinitescroll'], function (topicList) { var Tag = {}; Tag.init = function () { app.enterRoom('tags'); - topicList.init('tag', loadMoreTopics); - - function loadMoreTopics(after, direction, callback) { - infinitescroll.loadMore('topics.loadMoreFromSet', { - set: 'tag:' + ajaxify.data.tag + ':topics', - after: after, - direction: direction, - count: config.topicsPerPage, - }, callback); - } + topicList.init('tag'); }; return Tag; diff --git a/public/src/modules/topicList.js b/public/src/modules/topicList.js index b85e04aef9..6ff9e33c24 100644 --- a/public/src/modules/topicList.js +++ b/public/src/modules/topicList.js @@ -11,13 +11,6 @@ define('topicList', [ var TopicList = {}; var templateName = ''; - var tplToSort = { - recent: 'recent', - unread: 'unread', - popular: 'posts', - top: 'votes', - }; - var newTopicCount = 0; var newPostCount = 0; @@ -197,21 +190,15 @@ define('topicList', [ }); }; + function calculateNextPage(after, direction) { + return Math.floor(after / config.topicsPerPage) + (direction > 0 ? 1 : 0); + } + function loadTopicsAfter(after, direction, callback) { callback = callback || function () {}; var query = utils.params(); - infinitescroll.loadMore('topics.loadMoreSortedTopics', { - after: after, - direction: direction, - sort: tplToSort[templateName], - count: config.topicsPerPage, - cid: query.cid, - tags: query.tags, - query: query, - term: ajaxify.data.selectedTerm && ajaxify.data.selectedTerm.term, - filter: ajaxify.data.selectedFilter.filter, - set: topicListEl.attr('data-set') ? topicListEl.attr('data-set') : 'topics:recent', - }, callback); + query.page = calculateNextPage(after, direction); + infinitescroll.loadMoreXhr(query, callback); } function filterTopicsOnDom(topics) { diff --git a/src/socket.io/topics/infinitescroll.js b/src/socket.io/topics/infinitescroll.js index 03266a3059..93d2bbeb49 100644 --- a/src/socket.io/topics/infinitescroll.js +++ b/src/socket.io/topics/infinitescroll.js @@ -1,5 +1,7 @@ 'use strict'; +const winston = require('winston'); + const topics = require('../../topics'); const privileges = require('../../privileges'); const meta = require('../../meta'); @@ -62,6 +64,7 @@ module.exports = function (SocketTopics) { }; SocketTopics.loadMoreSortedTopics = async function (socket, data) { + winston.warn('[deprecated] use infinitescroll.loadMoreXhr'); // TODO: remove in 1.19.0 if (!data || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0) { throw new Error('[[error:invalid-data]]'); } @@ -85,6 +88,7 @@ module.exports = function (SocketTopics) { }; SocketTopics.loadMoreFromSet = async function (socket, data) { + winston.warn('[deprecated] use infinitescroll.loadMoreXhr'); // TODO: remove in 1.19.0 if (!data || !utils.isNumber(data.after) || parseInt(data.after, 10) < 0 || !data.set) { throw new Error('[[error:invalid-data]]'); }