feat: use all events in addTopicEvents

isekai-main
Barış Soner Uşaklı 1 year ago
parent f026e74038
commit 4bc21a2e8b

@ -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);
}
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();
});
$('[component="topic/event"] .timeago').timeago();
};
async function addNecroPostMessage() {

Loading…
Cancel
Save