mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 14:05:46 +01:00
Topic await errors (#7727)
* feat: derp await * feat: restore user.getSettings * feat: cleanup * feat: make tid const * feat: cleanup * fix: tests * feat: deprecate filter:controllers.topic.get * feat: rewrite post-index logic * feat: change calculation to match others * fix: use .async * feat: remove try/catch wrapper
This commit is contained in:
committed by
GitHub
parent
5e46cf9b09
commit
bd640a1107
@@ -34,26 +34,17 @@ module.exports = function (SocketTopics) {
|
||||
|
||||
userPrivileges = results.privileges;
|
||||
|
||||
var set = 'tid:' + data.tid + ':posts';
|
||||
if (data.topicPostSort === 'most_votes') {
|
||||
set = 'tid:' + data.tid + ':posts:votes';
|
||||
}
|
||||
var set = data.topicPostSort === 'most_votes' ? 'tid:' + data.tid + ':posts:votes' : 'tid:' + data.tid + ':posts';
|
||||
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 || 20, parseInt(data.count, 10) || meta.config.postsPerPage || 20) - 1);
|
||||
var infScrollPostsPerPage = Math.max(0, Math.min(meta.config.postsPerPage || 20, parseInt(data.count, 10) || meta.config.postsPerPage || 20));
|
||||
|
||||
if (data.direction > 0) {
|
||||
if (reverse) {
|
||||
start = results.topic.postcount - start;
|
||||
}
|
||||
} else if (reverse) {
|
||||
start = results.topic.postcount - start - infScrollPostsPerPage;
|
||||
} else {
|
||||
start -= infScrollPostsPerPage;
|
||||
if (data.direction === -1) {
|
||||
start -= (infScrollPostsPerPage + 1);
|
||||
}
|
||||
|
||||
var stop = start + (infScrollPostsPerPage);
|
||||
var stop = start + infScrollPostsPerPage - 1;
|
||||
|
||||
start = Math.max(0, start);
|
||||
stop = Math.max(0, stop);
|
||||
|
||||
Reference in New Issue
Block a user