From 2f770f98a7c67d492fb2b21a960abc8742c21ed8 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 00:08:14 -0500 Subject: [PATCH 01/22] Added answered.js to src/topics to allow users to mark topics as "answered" and "unanswered" --- src/topics/answered.js | 112 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 src/topics/answered.js diff --git a/src/topics/answered.js b/src/topics/answered.js new file mode 100644 index 0000000..91f2cf3 --- /dev/null +++ b/src/topics/answered.js @@ -0,0 +1,112 @@ +'use strict'; + +const topics = require.main.require('../topics'); +const plugins = require('../plugins'); + +module.exports = function (Topics) { + Topics.markAsAnswered = async function (tids, uid) { + if (!Array.isArray(tids) || !tids.length) { + return false; + } + + tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); + + if (!tids.length) { + return false; + } + + const topicData = await Topics.getTopicFields(tid, ['answered']); + if (!topicData || !topicData.cid) { + throw new Error('[[error:no-topic]]'); + } + + await Topics.setTopicField(tid, 'answered', 1); + plugins.hooks.fire('action:topic.answered', { topic: _.clone(topicData), uid: uid }); + return topicData; + + }; + + Topics.markAsUnanswered = async function (uid, tid) { + if (!Array.isArray(tids) || !tids.length) { + return false; + } + + tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); + + if (!tids.length) { + return false; + } + + const topicData = await Topics.getTopicFields(tid, ['answered']); + if (!topicData || !topicData.cid) { + throw new Error('[[error:no-topic]]'); + } + + await Topics.setTopicField(tid, 'answered', 0); + plugins.hooks.fire('action:topic.answered', { topic: _.clone(topicData), uid: uid }); + return topicData; + + }; + + Topics.getUnansweredTopics = async function (params) { + const unansweredTopics = { + showSelect: true, + nextStart: 0, + topics: [], + }; + let tids = await Topics.getUnansweredTids(params); + unansweredTopics.topicCount = tids.length; + + if (!tids.length) { + return unansweredTopics; + } + + tids = tids.slice(params.start, params.stop !== -1 ? params.stop + 1 : undefined); + + const topicData = await Topics.getTopicsByTids(tids, params.uid); + if (!topicData.length) { + return unansweredTopics; + } + Topics.calculateTopicIndices(topicData, params.start); + unansweredTopics.topics = topicData; + unansweredTopics.nextStart = params.stop + 1; + return unansweredTopics; + }; + + Topics.getUnAnsweredTids = async function (params) { + const results = await Topics.getAnsweredData(params); + return params.count ? results.counts : results.tids; + }; + + Topics.getAnsweredData = async function (params) { + const uid = parseInt(params.uid, 10); + + params.filter = params.filter || ''; + + if (params.cid && !Array.isArray(params.cid)) { + params.cid = [params.cid]; + } + + if (params.tag && !Array.isArray(params.tag)) { + params.tag = [params.tag]; + } + + const data = await getTids(params); + if (uid <= 0) { + return data; + } + + const result = await plugins.hooks.fire('filter:topics.getAnsweredTids', { + uid: uid, + tids: data.tids, + counts: data.counts, + tidsByFilter: data.tidsByFilter, + answeredCids: data.answeredCids, + cid: params.cid, + filter: params.filter, + query: params.query || {}, + }); + + return result; + }; +}; \ No newline at end of file From 0346dfa8b5a8d4f528dec9066a2fddae24ace8a3 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 00:10:39 -0500 Subject: [PATCH 02/22] Added line 21 in posts.js and line 36 in index.js to let questions be marked as "answered" --- src/topics/index.js | 1 + src/topics/posts.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/topics/index.js b/src/topics/index.js index 5724d8a..9631c52 100644 --- a/src/topics/index.js +++ b/src/topics/index.js @@ -33,6 +33,7 @@ require('./tools')(Topics); Topics.thumbs = require('./thumbs'); require('./bookmarks')(Topics); require('./merge')(Topics); +require('./answered')(Topics); Topics.events = require('./events'); Topics.exists = async function (tids) { diff --git a/src/topics/posts.js b/src/topics/posts.js index 73eb29b..033518f 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -18,6 +18,7 @@ module.exports = function (Topics) { Topics.onNewPostMade = async function (postData) { await Topics.updateLastPostTime(postData.tid, postData.timestamp); await Topics.addPostToTopic(postData.tid, postData); + postData.answered = false; }; Topics.getTopicPosts = async function (topicData, set, start, stop, uid, reverse) { From 4c69c73ecc54d32da7b4c525ed995159cdbf4f08 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 00:16:42 -0500 Subject: [PATCH 03/22] Added comments to src/topics/answered.js to clarify the source of helper functions --- src/topics/answered.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/topics/answered.js b/src/topics/answered.js index 91f2cf3..51ce270 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -3,6 +3,7 @@ const topics = require.main.require('../topics'); const plugins = require('../plugins'); + module.exports = function (Topics) { Topics.markAsAnswered = async function (tids, uid) { if (!Array.isArray(tids) || !tids.length) { @@ -20,6 +21,7 @@ module.exports = function (Topics) { throw new Error('[[error:no-topic]]'); } + // function from ../data.js await Topics.setTopicField(tid, 'answered', 1); plugins.hooks.fire('action:topic.answered', { topic: _.clone(topicData), uid: uid }); return topicData; @@ -48,6 +50,7 @@ module.exports = function (Topics) { }; + // based on getUnread functions from ../unread.js Topics.getUnansweredTopics = async function (params) { const unansweredTopics = { showSelect: true, From 7df8ad48dc218a91458082e286dc809f5bf11342 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 00:36:11 -0500 Subject: [PATCH 04/22] Removed unused constant in line 3 of answered.js --- src/topics/answered.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index 51ce270..3e80f3a 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -1,6 +1,6 @@ 'use strict'; -const topics = require.main.require('../topics'); +const topics = require('../topics'); const plugins = require('../plugins'); From 9319285a56f7da77e848434e85ed25a67209530b Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 00:40:06 -0500 Subject: [PATCH 05/22] Converted indentation from spaces to tabs in answered.js --- src/topics/answered.js | 130 ++++++++++++++++++++--------------------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index 3e80f3a..5b70081 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -5,53 +5,53 @@ const plugins = require('../plugins'); module.exports = function (Topics) { - Topics.markAsAnswered = async function (tids, uid) { - if (!Array.isArray(tids) || !tids.length) { - return false; - } + Topics.markAsAnswered = async function (tids, uid) { + if (!Array.isArray(tids) || !tids.length) { + return false; + } - tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); + tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); - if (!tids.length) { - return false; - } + if (!tids.length) { + return false; + } - const topicData = await Topics.getTopicFields(tid, ['answered']); - if (!topicData || !topicData.cid) { + const topicData = await Topics.getTopicFields(tid, ['answered']); + if (!topicData || !topicData.cid) { throw new Error('[[error:no-topic]]'); } - // function from ../data.js - await Topics.setTopicField(tid, 'answered', 1); + // function from ../data.js + await Topics.setTopicField(tid, 'answered', 1); plugins.hooks.fire('action:topic.answered', { topic: _.clone(topicData), uid: uid }); return topicData; - - }; + + }; - Topics.markAsUnanswered = async function (uid, tid) { - if (!Array.isArray(tids) || !tids.length) { - return false; - } + Topics.markAsUnanswered = async function (uid, tid) { + if (!Array.isArray(tids) || !tids.length) { + return false; + } - tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); + tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); - if (!tids.length) { - return false; - } + if (!tids.length) { + return false; + } - const topicData = await Topics.getTopicFields(tid, ['answered']); - if (!topicData || !topicData.cid) { + const topicData = await Topics.getTopicFields(tid, ['answered']); + if (!topicData || !topicData.cid) { throw new Error('[[error:no-topic]]'); } - await Topics.setTopicField(tid, 'answered', 0); + await Topics.setTopicField(tid, 'answered', 0); plugins.hooks.fire('action:topic.answered', { topic: _.clone(topicData), uid: uid }); return topicData; - - }; + + }; - // based on getUnread functions from ../unread.js - Topics.getUnansweredTopics = async function (params) { + // based on getUnread functions from ../unread.js + Topics.getUnansweredTopics = async function (params) { const unansweredTopics = { showSelect: true, nextStart: 0, @@ -76,40 +76,40 @@ module.exports = function (Topics) { return unansweredTopics; }; - Topics.getUnAnsweredTids = async function (params) { - const results = await Topics.getAnsweredData(params); - return params.count ? results.counts : results.tids; - }; - - Topics.getAnsweredData = async function (params) { - const uid = parseInt(params.uid, 10); - - params.filter = params.filter || ''; - - if (params.cid && !Array.isArray(params.cid)) { - params.cid = [params.cid]; - } - - if (params.tag && !Array.isArray(params.tag)) { - params.tag = [params.tag]; - } - - const data = await getTids(params); - if (uid <= 0) { - return data; - } - - const result = await plugins.hooks.fire('filter:topics.getAnsweredTids', { - uid: uid, - tids: data.tids, - counts: data.counts, - tidsByFilter: data.tidsByFilter, - answeredCids: data.answeredCids, - cid: params.cid, - filter: params.filter, - query: params.query || {}, - }); - - return result; - }; + Topics.getUnAnsweredTids = async function (params) { + const results = await Topics.getAnsweredData(params); + return params.count ? results.counts : results.tids; + }; + + Topics.getAnsweredData = async function (params) { + const uid = parseInt(params.uid, 10); + + params.filter = params.filter || ''; + + if (params.cid && !Array.isArray(params.cid)) { + params.cid = [params.cid]; + } + + if (params.tag && !Array.isArray(params.tag)) { + params.tag = [params.tag]; + } + + const data = await getTids(params); + if (uid <= 0) { + return data; + } + + const result = await plugins.hooks.fire('filter:topics.getAnsweredTids', { + uid: uid, + tids: data.tids, + counts: data.counts, + tidsByFilter: data.tidsByFilter, + answeredCids: data.answeredCids, + cid: params.cid, + filter: params.filter, + query: params.query || {}, + }); + + return result; + }; }; \ No newline at end of file From 97b5fc27a156ca34721e8424e5881fe1962b6ca3 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 00:54:54 -0500 Subject: [PATCH 06/22] Removed whitespace and unused variables in answered.js --- src/topics/answered.js | 40 +++++----------------------------------- 1 file changed, 5 insertions(+), 35 deletions(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index 5b70081..316572c 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -1,55 +1,28 @@ 'use strict'; -const topics = require('../topics'); const plugins = require('../plugins'); - module.exports = function (Topics) { - Topics.markAsAnswered = async function (tids, uid) { - if (!Array.isArray(tids) || !tids.length) { - return false; - } - - tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); - - if (!tids.length) { - return false; - } - + Topics.markAsAnswered = async function (uid, tid) { const topicData = await Topics.getTopicFields(tid, ['answered']); if (!topicData || !topicData.cid) { throw new Error('[[error:no-topic]]'); } - // function from ../data.js await Topics.setTopicField(tid, 'answered', 1); - plugins.hooks.fire('action:topic.answered', { topic: _.clone(topicData), uid: uid }); - return topicData; - + plugins.hooks.fire('action:topic.answered', { tid: tid, uid: uid }); + return topicData; }; - Topics.markAsUnanswered = async function (uid, tid) { - if (!Array.isArray(tids) || !tids.length) { - return false; - } - - tids = _.uniq(tids).filter(tid => tid && utils.isNumber(tid)); - - if (!tids.length) { - return false; - } - const topicData = await Topics.getTopicFields(tid, ['answered']); if (!topicData || !topicData.cid) { throw new Error('[[error:no-topic]]'); } await Topics.setTopicField(tid, 'answered', 0); - plugins.hooks.fire('action:topic.answered', { topic: _.clone(topicData), uid: uid }); - return topicData; - + plugins.hooks.fire('action:topic.answered', { tid: tid, uid: uid }); + return topicData; }; - // based on getUnread functions from ../unread.js Topics.getUnansweredTopics = async function (params) { const unansweredTopics = { @@ -75,12 +48,10 @@ module.exports = function (Topics) { unansweredTopics.nextStart = params.stop + 1; return unansweredTopics; }; - Topics.getUnAnsweredTids = async function (params) { const results = await Topics.getAnsweredData(params); return params.count ? results.counts : results.tids; }; - Topics.getAnsweredData = async function (params) { const uid = parseInt(params.uid, 10); @@ -109,7 +80,6 @@ module.exports = function (Topics) { filter: params.filter, query: params.query || {}, }); - return result; }; }; \ No newline at end of file From 6375500eead8153ba702394810c826f853353f11 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 01:02:59 -0500 Subject: [PATCH 07/22] Removed erroneous white space in posts.js --- src/topics/posts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topics/posts.js b/src/topics/posts.js index 033518f..a7fc8ec 100644 --- a/src/topics/posts.js +++ b/src/topics/posts.js @@ -18,7 +18,7 @@ module.exports = function (Topics) { Topics.onNewPostMade = async function (postData) { await Topics.updateLastPostTime(postData.tid, postData.timestamp); await Topics.addPostToTopic(postData.tid, postData); - postData.answered = false; + postData.answered = false; }; Topics.getTopicPosts = async function (topicData, set, start, stop, uid, reverse) { From f37ac83ca7d94840ba239d46a8be421c6a65695d Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 01:04:07 -0500 Subject: [PATCH 08/22] Added getTids function from unread.js to answered.js to retrieve topic IDs, removed errorneous whitespace --- src/topics/answered.js | 108 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 104 insertions(+), 4 deletions(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index 316572c..4127989 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -11,7 +11,7 @@ module.exports = function (Topics) { // function from ../data.js await Topics.setTopicField(tid, 'answered', 1); plugins.hooks.fire('action:topic.answered', { tid: tid, uid: uid }); - return topicData; + return topicData; }; Topics.markAsUnanswered = async function (uid, tid) { const topicData = await Topics.getTopicFields(tid, ['answered']); @@ -21,7 +21,7 @@ module.exports = function (Topics) { await Topics.setTopicField(tid, 'answered', 0); plugins.hooks.fire('action:topic.answered', { tid: tid, uid: uid }); - return topicData; + return topicData; }; // based on getUnread functions from ../unread.js Topics.getUnansweredTopics = async function (params) { @@ -49,8 +49,8 @@ module.exports = function (Topics) { return unansweredTopics; }; Topics.getUnAnsweredTids = async function (params) { - const results = await Topics.getAnsweredData(params); - return params.count ? results.counts : results.tids; + const results = await Topics.getAnsweredData(params); + return params.count ? results.counts : results.tids; }; Topics.getAnsweredData = async function (params) { const uid = parseInt(params.uid, 10); @@ -82,4 +82,104 @@ module.exports = function (Topics) { }); return result; }; + // from unread.js + async function getTids(params) { + const counts = { '': 0, new: 0, watched: 0, unreplied: 0 }; + const tidsByFilter = { '': [], new: [], watched: [], unreplied: [] }; + const unreadCids = []; + if (params.uid <= 0) { + return { counts, tids: [], tidsByFilter, unreadCids }; + } + + params.cutoff = await Topics.unreadCutoff(params.uid); + + const [followedTids, ignoredTids, categoryTids, userScores, tids_unread] = await Promise.all([ + getFollowedTids(params), + user.getIgnoredTids(params.uid, 0, -1), + getCategoryTids(params), + db.getSortedSetRevRangeByScoreWithScores(`uid:${params.uid}:tids_read`, 0, -1, '+inf', params.cutoff), + db.getSortedSetRevRangeWithScores(`uid:${params.uid}:tids_unread`, 0, -1), + ]); + + const userReadTimes = _.mapValues(_.keyBy(userScores, 'value'), 'score'); + const isTopicsFollowed = {}; + followedTids.forEach((t) => { + isTopicsFollowed[t.value] = true; + }); + const unreadFollowed = await db.isSortedSetMembers( + `uid:${params.uid}:followed_tids`, tids_unread.map(t => t.value) + ); + + tids_unread.forEach((t, i) => { + isTopicsFollowed[t.value] = unreadFollowed[i]; + }); + + const unreadTopics = _.unionWith(categoryTids, followedTids, (a, b) => a.value === b.value) + .filter(t => !ignoredTids.includes(t.value) && (!userReadTimes[t.value] || t.score > userReadTimes[t.value])) + .concat(tids_unread.filter(t => !ignoredTids.includes(t.value))) + .sort((a, b) => b.score - a.score); + + let tids = _.uniq(unreadTopics.map(topic => topic.value)).slice(0, 200); + + if (!tids.length) { + return { counts, tids, tidsByFilter, unreadCids }; + } + + const blockedUids = await user.blocks.list(params.uid); + + tids = await filterTidsThatHaveBlockedPosts({ + uid: params.uid, + tids: tids, + blockedUids: blockedUids, + recentTids: categoryTids, + }); + + tids = await privileges.topics.filterTids('topics:read', tids, params.uid); + const topicData = (await Topics.getTopicsFields(tids, ['tid', 'cid', 'uid', 'postcount', 'deleted', 'scheduled', 'tags'])) + .filter(t => t.scheduled || !t.deleted); + const topicCids = _.uniq(topicData.map(topic => topic.cid)).filter(Boolean); + + const categoryWatchState = await categories.getWatchState(topicCids, params.uid); + const userCidState = _.zipObject(topicCids, categoryWatchState); + + const filterCids = params.cid && params.cid.map(cid => parseInt(cid, 10)); + const filterTags = params.tag && params.tag.map(tag => String(tag)); + + topicData.forEach((topic) => { + if (topic && topic.cid && + (!filterCids || filterCids.includes(topic.cid)) && + (!filterTags || filterTags.every(tag => topic.tags.find(topicTag => topicTag.value === tag))) && + !blockedUids.includes(topic.uid)) { + if (isTopicsFollowed[topic.tid] || + [categories.watchStates.watching, categories.watchStates.tracking].includes(userCidState[topic.cid])) { + tidsByFilter[''].push(topic.tid); + unreadCids.push(topic.cid); + } + + if (isTopicsFollowed[topic.tid]) { + tidsByFilter.watched.push(topic.tid); + } + + if (topic.postcount <= 1) { + tidsByFilter.unreplied.push(topic.tid); + } + + if (!userReadTimes[topic.tid]) { + tidsByFilter.new.push(topic.tid); + } + } + }); + + counts[''] = tidsByFilter[''].length; + counts.watched = tidsByFilter.watched.length; + counts.unreplied = tidsByFilter.unreplied.length; + counts.new = tidsByFilter.new.length; + + return { + counts: counts, + tids: tidsByFilter[params.filter], + tidsByFilter: tidsByFilter, + unreadCids: unreadCids, + }; + } }; \ No newline at end of file From 450e1906183cc5dd4a28ad85acf2486acb48b709 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 01:13:33 -0500 Subject: [PATCH 09/22] Added constants of topics functionalities to answered.js and removed unused references in functions, minor spacing changes --- src/topics/answered.js | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index 4127989..3a59c55 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -1,7 +1,14 @@ 'use strict'; +const _ = require('lodash'); + +const db = require('../database'); +const user = require('../user'); +const categories = require('../categories'); +const privileges = require('../privileges'); const plugins = require('../plugins'); + module.exports = function (Topics) { Topics.markAsAnswered = async function (uid, tid) { const topicData = await Topics.getTopicFields(tid, ['answered']); @@ -93,10 +100,8 @@ module.exports = function (Topics) { params.cutoff = await Topics.unreadCutoff(params.uid); - const [followedTids, ignoredTids, categoryTids, userScores, tids_unread] = await Promise.all([ + const [followedTids, userScores, tids_unread] = await Promise.all([ getFollowedTids(params), - user.getIgnoredTids(params.uid, 0, -1), - getCategoryTids(params), db.getSortedSetRevRangeByScoreWithScores(`uid:${params.uid}:tids_read`, 0, -1, '+inf', params.cutoff), db.getSortedSetRevRangeWithScores(`uid:${params.uid}:tids_unread`, 0, -1), ]); @@ -114,26 +119,8 @@ module.exports = function (Topics) { isTopicsFollowed[t.value] = unreadFollowed[i]; }); - const unreadTopics = _.unionWith(categoryTids, followedTids, (a, b) => a.value === b.value) - .filter(t => !ignoredTids.includes(t.value) && (!userReadTimes[t.value] || t.score > userReadTimes[t.value])) - .concat(tids_unread.filter(t => !ignoredTids.includes(t.value))) - .sort((a, b) => b.score - a.score); - - let tids = _.uniq(unreadTopics.map(topic => topic.value)).slice(0, 200); - - if (!tids.length) { - return { counts, tids, tidsByFilter, unreadCids }; - } - const blockedUids = await user.blocks.list(params.uid); - tids = await filterTidsThatHaveBlockedPosts({ - uid: params.uid, - tids: tids, - blockedUids: blockedUids, - recentTids: categoryTids, - }); - tids = await privileges.topics.filterTids('topics:read', tids, params.uid); const topicData = (await Topics.getTopicsFields(tids, ['tid', 'cid', 'uid', 'postcount', 'deleted', 'scheduled', 'tags'])) .filter(t => t.scheduled || !t.deleted); @@ -182,4 +169,13 @@ module.exports = function (Topics) { unreadCids: unreadCids, }; } -}; \ No newline at end of file + async function getFollowedTids(params) { + const keys = params.cid ? + params.cid.map(cid => `cid:${cid}:tids:lastposttime`) : + 'topics:recent'; + + const recentTopicData = await db.getSortedSetRevRangeByScoreWithScores(keys, 0, -1, '+inf', params.cutoff); + const isFollowed = await db.isSortedSetMembers(`uid:${params.uid}:followed_tids`, recentTopicData.map(t => t.tid)); + return recentTopicData.filter((t, i) => isFollowed[i]); + } +}; From 5d913173366d0d68681db00c1ee4f63752c916a0 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 01:17:41 -0500 Subject: [PATCH 10/22] Fixed syntax error on line 124 in answered.js --- src/topics/answered.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index 3a59c55..66bc866 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -121,7 +121,7 @@ module.exports = function (Topics) { const blockedUids = await user.blocks.list(params.uid); - tids = await privileges.topics.filterTids('topics:read', tids, params.uid); + let tids = await privileges.topics.filterTids('topics:read', tids, params.uid); const topicData = (await Topics.getTopicsFields(tids, ['tid', 'cid', 'uid', 'postcount', 'deleted', 'scheduled', 'tags'])) .filter(t => t.scheduled || !t.deleted); const topicCids = _.uniq(topicData.map(topic => topic.cid)).filter(Boolean); From 53d4d1fb856e5fdd8fd3e4e39290f749c8e9750a Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 01:22:41 -0500 Subject: [PATCH 11/22] Fixed variable being referenced before initialization error in answered.js --- src/topics/answered.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index 66bc866..cd5d766 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -120,8 +120,9 @@ module.exports = function (Topics) { }); const blockedUids = await user.blocks.list(params.uid); + let tids = _.uniq(unreadTopics.map(topic => topic.value)).slice(0, 200); - let tids = await privileges.topics.filterTids('topics:read', tids, params.uid); + tids = await privileges.topics.filterTids('topics:read', tids, params.uid); const topicData = (await Topics.getTopicsFields(tids, ['tid', 'cid', 'uid', 'postcount', 'deleted', 'scheduled', 'tags'])) .filter(t => t.scheduled || !t.deleted); const topicCids = _.uniq(topicData.map(topic => topic.cid)).filter(Boolean); From 3be1afc1648b905613c1bf32c8eadad63ddc0c77 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 01:29:01 -0500 Subject: [PATCH 12/22] Added constant unreadTopics to answered.js to fix referencing issue --- src/topics/answered.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/topics/answered.js b/src/topics/answered.js index cd5d766..ce3ab02 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -119,6 +119,10 @@ module.exports = function (Topics) { isTopicsFollowed[t.value] = unreadFollowed[i]; }); + const unreadTopics = _.unionWith(categoryTids, followedTids, (a, b) => a.value === b.value) + .filter(t => !ignoredTids.includes(t.value) && (!userReadTimes[t.value] || t.score > userReadTimes[t.value])) + .concat(tids_unread.filter(t => !ignoredTids.includes(t.value))) + .sort((a, b) => b.score - a.score); const blockedUids = await user.blocks.list(params.uid); let tids = _.uniq(unreadTopics.map(topic => topic.value)).slice(0, 200); From a89b4ad49c06f0832a730fd265c5fc0c83a91db8 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Mon, 10 Feb 2025 01:34:19 -0500 Subject: [PATCH 13/22] Removed unused references to ignoredTids in answered.js --- src/topics/answered.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/topics/answered.js b/src/topics/answered.js index ce3ab02..115939c 100644 --- a/src/topics/answered.js +++ b/src/topics/answered.js @@ -119,10 +119,7 @@ module.exports = function (Topics) { isTopicsFollowed[t.value] = unreadFollowed[i]; }); - const unreadTopics = _.unionWith(categoryTids, followedTids, (a, b) => a.value === b.value) - .filter(t => !ignoredTids.includes(t.value) && (!userReadTimes[t.value] || t.score > userReadTimes[t.value])) - .concat(tids_unread.filter(t => !ignoredTids.includes(t.value))) - .sort((a, b) => b.score - a.score); + const unreadTopics = followedTids; const blockedUids = await user.blocks.list(params.uid); let tids = _.uniq(unreadTopics.map(topic => topic.value)).slice(0, 200); From 22d0bb2e60369026a996e483e0ed42d059bb5461 Mon Sep 17 00:00:00 2001 From: Bing Bhakdibhumi Date: Fri, 21 Feb 2025 13:29:19 -0500 Subject: [PATCH 14/22] added dummy front end headers to topic templates --- .../templates/partials/topic-list-bar.tpl | 8 ++++++++ nodebb-theme-harmony/templates/topic.tpl | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/nodebb-theme-harmony/templates/partials/topic-list-bar.tpl b/nodebb-theme-harmony/templates/partials/topic-list-bar.tpl index 53f558c..892b261 100644 --- a/nodebb-theme-harmony/templates/partials/topic-list-bar.tpl +++ b/nodebb-theme-harmony/templates/partials/topic-list-bar.tpl @@ -1,5 +1,13 @@