mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
refactor(topic-events): expose addTopicEvents method in topic posts lib
+ allow it to accept an array of events, or fall back to ajaxify data otherwise
This commit is contained in:
@@ -271,11 +271,16 @@ define('forum/topic/posts', [
|
|||||||
posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
posts.find('[component="post/content"] img:not(.not-responsive)').addClass('img-responsive');
|
||||||
Posts.addBlockquoteEllipses(posts);
|
Posts.addBlockquoteEllipses(posts);
|
||||||
hidePostToolsForDeletedPosts(posts);
|
hidePostToolsForDeletedPosts(posts);
|
||||||
addTopicEvents();
|
Posts.addTopicEvents();
|
||||||
addNecroPostMessage();
|
addNecroPostMessage();
|
||||||
};
|
};
|
||||||
|
|
||||||
function addTopicEvents() {
|
Posts.addTopicEvents = function (events) {
|
||||||
|
events = events || ajaxify.data.events;
|
||||||
|
if (!events || !Array.isArray(events)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (config.topicPostSort !== 'newest_to_oldest' && config.topicPostSort !== 'oldest_to_newest') {
|
if (config.topicPostSort !== 'newest_to_oldest' && config.topicPostSort !== 'oldest_to_newest') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -283,7 +288,7 @@ define('forum/topic/posts', [
|
|||||||
let postTimestamps = ajaxify.data.posts.map(post => post.timestamp);
|
let postTimestamps = ajaxify.data.posts.map(post => post.timestamp);
|
||||||
|
|
||||||
const reverse = config.topicPostSort === 'newest_to_oldest';
|
const reverse = config.topicPostSort === 'newest_to_oldest';
|
||||||
const events = ajaxify.data.events.slice(0);
|
events = events.slice(0);
|
||||||
if (reverse) {
|
if (reverse) {
|
||||||
events.reverse();
|
events.reverse();
|
||||||
postTimestamps = postTimestamps.slice(1); // OP is always at top, so exclude from calculations
|
postTimestamps = postTimestamps.slice(1); // OP is always at top, so exclude from calculations
|
||||||
@@ -314,7 +319,7 @@ define('forum/topic/posts', [
|
|||||||
})).then(() => {
|
})).then(() => {
|
||||||
$('[component="topic/event"] .timeago').timeago();
|
$('[component="topic/event"] .timeago').timeago();
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function addNecroPostMessage() {
|
function addNecroPostMessage() {
|
||||||
var necroThreshold = ajaxify.data.necroThreshold * 24 * 60 * 60 * 1000;
|
var necroThreshold = ajaxify.data.necroThreshold * 24 * 60 * 60 * 1000;
|
||||||
|
|||||||
Reference in New Issue
Block a user