From 33d1cc6d0f849a165e268517d4e2a15cee3d282b Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 10 Mar 2017 15:56:45 -0500 Subject: [PATCH 1/2] replace erroring line with operator-assignment --- src/socket.io/topics/infinitescroll.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/socket.io/topics/infinitescroll.js b/src/socket.io/topics/infinitescroll.js index cf7c37e050..753b050699 100644 --- a/src/socket.io/topics/infinitescroll.js +++ b/src/socket.io/topics/infinitescroll.js @@ -49,7 +49,7 @@ module.exports = function (SocketTopics) { } else if (reverse) { start = results.topic.postcount - start - infScrollPostsPerPage; } else { - start = start - infScrollPostsPerPage; + start -= infScrollPostsPerPage; } var stop = start + (infScrollPostsPerPage); From 4ba795b5f2263adb2f9c04eb1e11f0184170ab2c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 10 Mar 2017 16:29:40 -0500 Subject: [PATCH 2/2] adding fallbacks for meta/config.topicsPerPage --- src/socket.io/topics/infinitescroll.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/socket.io/topics/infinitescroll.js b/src/socket.io/topics/infinitescroll.js index 753b050699..ec82038e0d 100644 --- a/src/socket.io/topics/infinitescroll.js +++ b/src/socket.io/topics/infinitescroll.js @@ -40,7 +40,7 @@ module.exports = function (SocketTopics) { var reverse = data.topicPostSort === 'newest_to_oldest' || data.topicPostSort === 'most_votes'; var start = Math.max(0, parseInt(data.after, 10)); - var infScrollPostsPerPage = Math.max(0, Math.min(meta.config.postsPerPage, parseInt(data.postsPerPage, 10) || meta.config.postsPerPage) - 1); + var infScrollPostsPerPage = Math.max(0, Math.min(meta.config.postsPerPage || 20, parseInt(data.postsPerPage, 10) || meta.config.postsPerPage || 20) - 1); if (data.direction > 0) { if (reverse) { @@ -93,7 +93,7 @@ module.exports = function (SocketTopics) { } var start = parseInt(data.after, 10); - var stop = start + Math.max(0, Math.min(meta.config.topicsPerPage, parseInt(data.topicsPerPage, 10) || meta.config.topicsPerPage) - 1); + var stop = start + Math.max(0, Math.min(meta.config.topicsPerPage || 20, parseInt(data.topicsPerPage, 10) || meta.config.topicsPerPage || 20) - 1); topics.getUnreadTopics({ cid: data.cid, uid: socket.uid, start: start, stop: stop, filter: data.filter }, callback); }; @@ -104,7 +104,7 @@ module.exports = function (SocketTopics) { } var start = parseInt(data.after, 10); - var stop = start + Math.max(0, Math.min(meta.config.topicsPerPage, parseInt(data.topicsPerPage, 10) || meta.config.topicsPerPage) - 1); + var stop = start + Math.max(0, Math.min(meta.config.topicsPerPage || 20, parseInt(data.topicsPerPage, 10) || meta.config.topicsPerPage || 20) - 1); topics.getRecentTopics(data.cid, socket.uid, start, stop, data.filter, callback); }; @@ -115,7 +115,7 @@ module.exports = function (SocketTopics) { } var start = parseInt(data.after, 10); - var stop = start + Math.max(0, Math.min(meta.config.topicsPerPage, parseInt(data.topicsPerPage, 10) || meta.config.topicsPerPage) - 1); + var stop = start + Math.max(0, Math.min(meta.config.topicsPerPage || 20, parseInt(data.topicsPerPage, 10) || meta.config.topicsPerPage || 20) - 1); topics.getTopicsFromSet(data.set, socket.uid, start, stop, callback); };