mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor: wrap around if at end
remove debug log dont focus input on mobile
This commit is contained in:
@@ -56,7 +56,9 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct
|
|||||||
|
|
||||||
paginationBlockEl.off('shown.bs.dropdown', '.wrapper').on('shown.bs.dropdown', '.wrapper', function () {
|
paginationBlockEl.off('shown.bs.dropdown', '.wrapper').on('shown.bs.dropdown', '.wrapper', function () {
|
||||||
setTimeout(async function () {
|
setTimeout(async function () {
|
||||||
$('.pagination-block input').focus();
|
if (utils.findBootstrapEnvironment() === 'lg') {
|
||||||
|
$('.pagination-block input').focus();
|
||||||
|
}
|
||||||
const postCountInTopic = await socket.emit('topics.getPostCountInTopic', ajaxify.data.tid);
|
const postCountInTopic = await socket.emit('topics.getPostCountInTopic', ajaxify.data.tid);
|
||||||
if (postCountInTopic > 0) {
|
if (postCountInTopic > 0) {
|
||||||
paginationBlockEl.find('#myNextPostBtn').removeAttr('disabled');
|
paginationBlockEl.find('#myNextPostBtn').removeAttr('disabled');
|
||||||
@@ -107,10 +109,9 @@ define('navigator', ['forum/pagination', 'components', 'hooks', 'alerts'], funct
|
|||||||
if (ajaxify.data.template.topic) {
|
if (ajaxify.data.template.topic) {
|
||||||
let nextIndex = await getNext(index);
|
let nextIndex = await getNext(index);
|
||||||
if (lastNextIndex === nextIndex) { // handles last post in pagination
|
if (lastNextIndex === nextIndex) { // handles last post in pagination
|
||||||
console.log('fail', nextIndex, lastNextIndex);
|
|
||||||
nextIndex = await getNext(nextIndex);
|
nextIndex = await getNext(nextIndex);
|
||||||
}
|
}
|
||||||
if (nextIndex) {
|
if (nextIndex && index !== nextIndex + 1) {
|
||||||
lastNextIndex = nextIndex;
|
lastNextIndex = nextIndex;
|
||||||
$(window).one('action:ajaxify.end', function () {
|
$(window).one('action:ajaxify.end', function () {
|
||||||
if (paginationBlockEl.find('.dropdown-menu').is(':hidden')) {
|
if (paginationBlockEl.find('.dropdown-menu').is(':hidden')) {
|
||||||
|
|||||||
@@ -88,13 +88,21 @@ SocketTopics.getMyNextPostIndex = async function (socket, data) {
|
|||||||
cache.set(cacheKey, pids, 30000);
|
cache.set(cacheKey, pids, 30000);
|
||||||
return pids;
|
return pids;
|
||||||
}
|
}
|
||||||
|
const postCountInTopic = await db.sortedSetScore(`tid:${data.tid}:posters`, socket.uid);
|
||||||
|
if (postCountInTopic <= 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
const [topicPids, userPidsInCategory] = await Promise.all([
|
const [topicPids, userPidsInCategory] = await Promise.all([
|
||||||
getTopicPids(data.index),
|
getTopicPids(data.index),
|
||||||
getUserPids(),
|
getUserPids(),
|
||||||
]);
|
]);
|
||||||
const userPidsInTopic = _.intersection(topicPids, userPidsInCategory);
|
const userPidsInTopic = _.intersection(topicPids, userPidsInCategory);
|
||||||
if (!userPidsInTopic.length) {
|
if (!userPidsInTopic.length) {
|
||||||
|
if (postCountInTopic > 0) {
|
||||||
|
// wrap around to beginning
|
||||||
|
const wrapIndex = await SocketTopics.getMyNextPostIndex(socket, { ...data, index: 1 });
|
||||||
|
return wrapIndex;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return await posts.getPidIndex(userPidsInTopic[0], data.tid, data.sort);
|
return await posts.getPidIndex(userPidsInTopic[0], data.tid, data.sort);
|
||||||
|
|||||||
Reference in New Issue
Block a user