Node.js based forum software built for the modern web
closes #4772
barisusakli4bbc8110a935
diff --git a/public/src/client/topic.js b/public/src/client/topic.jsindex 6d9daad827..4c3c4daa81 100644--- a/public/src/client/topic.js+++ b/public/src/client/topic.js@@ -242,37 +242,40 @@ define('forum/topic', [Topic.navigatorCallback = function(index, elementCount, threshold) {var path = ajaxify.removeRelativePath(window.location.pathname.slice(1));if (!path.startsWith('topic')) {- return 1;+ return;}- if (!navigator.scrollActive) {- var parts = ajaxify.removeRelativePath(window.location.pathname.slice(1)).split('/');- var topicId = parts[1],- slug = parts[2];- var newUrl = 'topic/' + topicId + '/' + (slug ? slug : '');- if (index > 1) {- newUrl += '/' + index;+ if (navigator.scrollActive) {+ return;+ }++ posts.loadImages(threshold);++ var newUrl = 'topic/' + ajaxify.data.slug + (index > 1 ? ('/' + index) : '');++ if (newUrl !== currentUrl) {++ if (Topic.replaceURLTimeout) {+ clearTimeout(Topic.replaceURLTimeout);}- posts.loadImages(threshold);+ Topic.replaceURLTimeout = setTimeout(function() {- if (newUrl !== currentUrl) {- if (Topic.replaceURLTimeout) {- clearTimeout(Topic.replaceURLTimeout);+ if (index >= elementCount && app.user.uid) {+ socket.emit('topics.markAsRead', [ajaxify.data.tid]);}- Topic.replaceURLTimeout = setTimeout(function() {- updateUserBookmark(index);-- Topic.replaceURLTimeout = 0;- if (history.replaceState) {- var search = (window.location.search ? window.location.search : '');- history.replaceState({- url: newUrl + search- }, null, window.location.protocol + '//' + window.location.host + RELATIVE_PATH + '/' + newUrl + search);- }- currentUrl = newUrl;- }, 500);- }++ updateUserBookmark(index);++ Topic.replaceURLTimeout = 0;+ if (history.replaceState) {+ var search = (window.location.search ? window.location.search : '');+ history.replaceState({+ url: newUrl + search+ }, null, window.location.protocol + '//' + window.location.host + RELATIVE_PATH + '/' + newUrl + search);+ }+ currentUrl = newUrl;+ }, 500);}};diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.jsindex 31cf70b30e..aaf188c591 100644--- a/public/src/client/topic/posts.js+++ b/public/src/client/topic/posts.js@@ -225,9 +225,6 @@ define('forum/topic/posts', [if (data && data.posts && data.posts.length) {createNewPosts(data, replies, direction, done);} else {- if (app.user.uid) {- socket.emit('topics.markAsRead', [tid]);- }navigator.update();done();}diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.jsindex 0d1747598c..0fb1a7f368 100644--- a/public/src/modules/navigator.js+++ b/public/src/modules/navigator.js@@ -17,8 +17,15 @@ define('navigator', ['forum/pagination', 'components'], function(pagination, comnavigator.callback = callback;toTop = toTop || 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) {e.stopPropagation();diff --git a/src/topics/unread.js b/src/topics/unread.jsindex b4900be3a1..61fef8b65e 100644--- a/src/topics/unread.js+++ b/src/topics/unread.js@@ -255,7 +255,7 @@ module.exports = function(Topics) {async.parallel({markRead: async.apply(db.sortedSetAdd, 'uid:' + uid + ':tids_read', scores, 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);},function (results, next) {