fix(topic-events): repeated invocations of Posts.addTopicEvents caused dupes to be added to DOM

This commit is contained in:
Julian Lam
2021-01-12 11:42:06 -05:00
parent 9559fad8ac
commit df2fdd56ba
2 changed files with 5 additions and 1 deletions

View File

@@ -285,6 +285,10 @@ define('forum/topic/posts', [
return;
}
// Filter out events already in DOM
const eventIdsInDOM = Array.from(document.querySelectorAll('[component="topic/event"]')).map(el => parseInt(el.getAttribute('data-topic-event-id'), 10));
events = events.filter(event => !eventIdsInDOM.includes(event.id));
let postTimestamps = ajaxify.data.posts.map(post => post.timestamp);
const reverse = config.topicPostSort === 'newest_to_oldest';