From a584dae65027bd9f0c42c645e438142a2a6c6456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Fri, 23 Sep 2022 10:42:15 -0400 Subject: [PATCH] feat: add relevant topic events to post objects see https://github.com/NodeBB/nodebb-theme-persona/commit/c9604f216a87ae867a7c31e10abbb43f30e2f19a --- public/src/modules/helpers.common.js | 1 + src/topics/index.js | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/public/src/modules/helpers.common.js b/public/src/modules/helpers.common.js index 25907fb446..04ab16c3f8 100644 --- a/public/src/modules/helpers.common.js +++ b/public/src/modules/helpers.common.js @@ -181,6 +181,7 @@ module.exports = function (utils, Benchpress, relative_path) { } function renderTopicEvents(index, sort) { + console.warn('[renderTopicEvents] deprecated, use a partial at partials/topic/event.tpl'); if (sort === 'most_votes') { return ''; } diff --git a/src/topics/index.js b/src/topics/index.js index 94f9803f5c..b6dd08e817 100644 --- a/src/topics/index.js +++ b/src/topics/index.js @@ -185,6 +185,12 @@ Topics.getTopicWithPosts = async function (topicData, set, uid, start, stop, rev topicData.thumbs = thumbs[0]; topicData.posts = posts; topicData.events = events; + topicData.posts.forEach((p) => { + p.events = events.filter( + event => event.timestamp >= p.eventStart && event.timestamp < p.eventEnd + ); + }); + topicData.category = category; topicData.tagWhitelist = tagWhitelist[0]; topicData.minTags = category.minTags;