Node.js based forum software built for the modern web
feat: add data-allow-dupe and data-navigator-ignore
Barış Soner Uşaklı92f5c146fddc
diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.jsindex 6653941d64..3c2e009cde 100644--- a/public/src/client/topic/posts.js+++ b/public/src/client/topic/posts.js@@ -189,7 +189,7 @@ define('forum/topic/posts', [}data.posts = data.posts.filter(function (post) {- return post.index === -1 || $('[component="post"][data-pid="' + post.pid + '"]').length === 0;+ return post.allowDupe || $('[component="post"][data-pid="' + post.pid + '"]').length === 0;});}@@ -214,9 +214,9 @@ define('forum/topic/posts', [html = html.filter(function () {const $this = $(this);const pid = $this.attr('data-pid');- const index = parseInt($this.attr('data-index'), 10);+ const allowDupe = $this.attr('data-allow-dupe');const isPost = $this.is('[component="post"]');- return !isPost || index === -1 || (pid && $('[component="post"][data-pid="' + pid + '"]').length === 0);+ return !isPost || allowDupe || (pid && $('[component="post"][data-pid="' + pid + '"]').length === 0);});const removedEls = infinitescroll.removeExtra($('[component="post"]'), direction, Math.max(20, config.postsPerPage * 2));diff --git a/public/src/modules/navigator.js b/public/src/modules/navigator.jsindex 98c0752312..b0e75ec8e9 100644--- a/public/src/modules/navigator.js+++ b/public/src/modules/navigator.js@@ -478,7 +478,7 @@ define('navigator', [navigator.update = function () {let newIndex = index;- const els = $(navigator.selector);+ const els = $(navigator.selector).filter((i, el) => !el.getAttribute('data-navigator-ignore'));if (els.length) {newIndex = parseInt(els.first().attr('data-index'), 10) + 1;}@@ -585,7 +585,7 @@ define('navigator', [};navigator.scrollTop = function (index) {- if ($(navigator.selector + '[data-index="' + index + '"]').length) {+ if ($(`${navigator.selector}[data-index="${index}"]:not([data-navigator-ignore])`).length) {navigator.scrollToIndex(index, true);} else {ajaxify.go(generateUrl());@@ -597,7 +597,7 @@ define('navigator', [return;}- if ($(navigator.selector + '[data-index="' + index + '"]').length) {+ if ($(`${navigator.selector}[data-index="${index}"]:not([data-navigator-ignore])`).length) {navigator.scrollToIndex(index, true);} else {index = parseInt(index, 10) + 1;@@ -654,7 +654,7 @@ define('navigator', [};navigator.scrollToPostIndex = function (postIndex, highlight, duration) {- const scrollTo = components.get('post', 'index', postIndex);+ const scrollTo = $(`[component="post"][data-index="${postIndex}"]:not([data-navigator-ignore])`);navigator.scrollToElement(scrollTo, highlight, duration, postIndex);};diff --git a/src/views/partials/data/topic.tpl b/src/views/partials/data/topic.tplindex ea6fea2a3c..4c3b70640c 100644--- a/src/views/partials/data/topic.tpl+++ b/src/views/partials/data/topic.tpl@@ -1 +1 @@-data-index="{posts.index}" data-pid="{posts.pid}" data-uid="{posts.uid}" data-timestamp="{posts.timestamp}" data-username="{posts.user.username}" data-userslug="{posts.user.userslug}" itemscope itemtype="http://schema.org/Comment"\ No newline at end of file+data-index="{posts.index}" data-pid="{posts.pid}" data-uid="{posts.uid}" data-timestamp="{posts.timestamp}" data-username="{posts.user.username}" data-userslug="{posts.user.userslug}"{{{ if posts.allowDupe }}} data-allow-dupe="1"{{{ end }}}{{{ if posts.navigatorIgnore }}} data-navigator-ignore="1"{{{ end }}} itemscope itemtype="http://schema.org/Comment"\ No newline at end of file