v1.18.x
barisusakli 9 years ago
parent 1bf6054345
commit 4bbc8110a9

@ -242,25 +242,29 @@ define('forum/topic', [
Topic.navigatorCallback = function(index, elementCount, threshold) { Topic.navigatorCallback = function(index, elementCount, threshold) {
var path = ajaxify.removeRelativePath(window.location.pathname.slice(1)); var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));
if (!path.startsWith('topic')) { if (!path.startsWith('topic')) {
return 1; return;
} }
if (!navigator.scrollActive) { if (navigator.scrollActive) {
var parts = ajaxify.removeRelativePath(window.location.pathname.slice(1)).split('/'); return;
var topicId = parts[1],
slug = parts[2];
var newUrl = 'topic/' + topicId + '/' + (slug ? slug : '');
if (index > 1) {
newUrl += '/' + index;
} }
posts.loadImages(threshold); posts.loadImages(threshold);
var newUrl = 'topic/' + ajaxify.data.slug + (index > 1 ? ('/' + index) : '');
if (newUrl !== currentUrl) { if (newUrl !== currentUrl) {
if (Topic.replaceURLTimeout) { if (Topic.replaceURLTimeout) {
clearTimeout(Topic.replaceURLTimeout); clearTimeout(Topic.replaceURLTimeout);
} }
Topic.replaceURLTimeout = setTimeout(function() { Topic.replaceURLTimeout = setTimeout(function() {
if (index >= elementCount && app.user.uid) {
socket.emit('topics.markAsRead', [ajaxify.data.tid]);
}
updateUserBookmark(index); updateUserBookmark(index);
Topic.replaceURLTimeout = 0; Topic.replaceURLTimeout = 0;
@ -273,7 +277,6 @@ define('forum/topic', [
currentUrl = newUrl; currentUrl = newUrl;
}, 500); }, 500);
} }
}
}; };
function updateUserBookmark(index) { function updateUserBookmark(index) {

@ -225,9 +225,6 @@ define('forum/topic/posts', [
if (data && data.posts && data.posts.length) { if (data && data.posts && data.posts.length) {
createNewPosts(data, replies, direction, done); createNewPosts(data, replies, direction, done);
} else { } else {
if (app.user.uid) {
socket.emit('topics.markAsRead', [tid]);
}
navigator.update(); navigator.update();
done(); done();
} }

@ -17,8 +17,15 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, com
navigator.callback = callback; navigator.callback = callback;
toTop = toTop || function() {}; toTop = toTop || function() {};
toBottom = toBottom || function() {}; toBottom = toBottom || function() {};
var navigatorUpdateTimeoutId = 0;
$(window).off('scroll', navigator.update).on('scroll', navigator.update); $(window).off('scroll', navigator.update).on('scroll', function() {
if (navigatorUpdateTimeoutId) {
clearTimeout(navigatorUpdateTimeoutId);
navigatorUpdateTimeoutId = 0;
}
navigatorUpdateTimeoutId = setTimeout(navigator.update, 100);
});
$('.pagination-block .dropdown-menu').off('click').on('click', function(e) { $('.pagination-block .dropdown-menu').off('click').on('click', function(e) {
e.stopPropagation(); e.stopPropagation();

@ -255,7 +255,7 @@ module.exports = function(Topics) {
async.parallel({ async.parallel({
markRead: async.apply(db.sortedSetAdd, 'uid:' + uid + ':tids_read', scores, tids), markRead: async.apply(db.sortedSetAdd, 'uid:' + uid + ':tids_read', scores, tids),
markUnread: async.apply(db.sortedSetRemove, 'uid:' + uid + ':tids_unread', tids), markUnread: async.apply(db.sortedSetRemove, 'uid:' + uid + ':tids_unread', tids),
topicData: async.apply( Topics.getTopicsFields, tids, ['cid']) topicData: async.apply(Topics.getTopicsFields, tids, ['cid'])
}, next); }, next);
}, },
function (results, next) { function (results, next) {

Loading…
Cancel
Save