feat: add topicIndex to category page

This commit is contained in:
Barış Soner Uşaklı
2020-09-10 18:26:56 -04:00
parent 4969c86909
commit c1c617b323
2 changed files with 3 additions and 3 deletions

View File

@@ -41,10 +41,9 @@ define('forum/category', [
};
function handleScrollToTopicIndex() {
var parts = window.location.pathname.split('/');
var topicIndex = parts[parts.length - 1];
var topicIndex = ajaxify.data.topicIndex;
if (topicIndex && utils.isNumber(topicIndex)) {
topicIndex = Math.max(0, parseInt(topicIndex, 10) - 1);
topicIndex = Math.max(0, parseInt(topicIndex, 10));
if (topicIndex && window.location.search.indexOf('page=') === -1) {
navigator.scrollToElement($('[component="category/topic"][data-index="' + topicIndex + '"]'), true, 0);
}

View File

@@ -96,6 +96,7 @@ categoryController.get = async function (req, res, next) {
categoryData.privileges = userPrivileges;
categoryData.showSelect = userPrivileges.editable;
categoryData.showTopicTools = userPrivileges.editable;
categoryData.topicIndex = topicIndex;
categoryData.rssFeedUrl = nconf.get('url') + '/category/' + categoryData.cid + '.rss';
if (parseInt(req.uid, 10)) {
categories.markAsRead([cid], req.uid);