mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-31 19:15:58 +01:00
feat: use all events in addTopicEvents
This commit is contained in:
@@ -295,25 +295,27 @@ define('forum/topic/posts', [
|
||||
await addNecroPostMessage();
|
||||
};
|
||||
|
||||
Posts.addTopicEvents = function (events) {
|
||||
Posts.addTopicEvents = async function (events) {
|
||||
if (config.topicPostSort === 'most_votes') {
|
||||
return;
|
||||
}
|
||||
const event = events[0];
|
||||
app.parseAndTranslate('partials/topic/event', event).then(function (translated) {
|
||||
if (config.topicPostSort === 'oldest_to_newest') {
|
||||
$('[component="topic"]').append(translated);
|
||||
} else if (config.topicPostSort === 'newest_to_oldest') {
|
||||
const mainPost = $('[component="topic"] [component="post"][data-index="0"]');
|
||||
if (mainPost.length) {
|
||||
$(translated).insertAfter(mainPost);
|
||||
} else {
|
||||
$('[component="topic"]').prepend(translated);
|
||||
}
|
||||
}
|
||||
|
||||
$('[component="topic/event"] .timeago').timeago();
|
||||
});
|
||||
const translated = await Promise.all(
|
||||
events.map(event => app.parseAndTranslate('partials/topic/event', event))
|
||||
);
|
||||
|
||||
if (config.topicPostSort === 'oldest_to_newest') {
|
||||
$('[component="topic"]').append(translated);
|
||||
} else if (config.topicPostSort === 'newest_to_oldest') {
|
||||
const mainPost = $('[component="topic"] [component="post"][data-index="0"]');
|
||||
if (mainPost.length) {
|
||||
mainPost.after(translated.reverse());
|
||||
} else {
|
||||
$('[component="topic"]').prepend(translated.reverse());
|
||||
}
|
||||
}
|
||||
|
||||
$('[component="topic/event"] .timeago').timeago();
|
||||
};
|
||||
|
||||
async function addNecroPostMessage() {
|
||||
|
||||
Reference in New Issue
Block a user