|
|
|
@ -230,7 +230,8 @@ define('forum/topic/posts', [
|
|
|
|
|
components.get('topic').append(html);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
infinitescroll.removeExtra($('[component="post"]'), direction, Math.max(20, config.postsPerPage * 2));
|
|
|
|
|
const removedEls = infinitescroll.removeExtra($('[component="post"]'), direction, Math.max(20, config.postsPerPage * 2));
|
|
|
|
|
removeNecroPostMessages(removedEls);
|
|
|
|
|
|
|
|
|
|
hooks.fire('action:posts.loaded', { posts: data.posts });
|
|
|
|
|
|
|
|
|
@ -309,14 +310,14 @@ define('forum/topic/posts', [
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function addNecroPostMessage(callback) {
|
|
|
|
|
function addNecroPostMessage() {
|
|
|
|
|
const necroThreshold = ajaxify.data.necroThreshold * 24 * 60 * 60 * 1000;
|
|
|
|
|
if (!necroThreshold || (config.topicPostSort !== 'newest_to_oldest' && config.topicPostSort !== 'oldest_to_newest')) {
|
|
|
|
|
return callback && callback();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const postEls = $('[component="post"]').toArray();
|
|
|
|
|
Promise.all(postEls.map(function (post) {
|
|
|
|
|
postEls.forEach(function (post) {
|
|
|
|
|
post = $(post);
|
|
|
|
|
const prev = post.prev('[component="post"]');
|
|
|
|
|
if (post.is(':has(.necro-post)') || !prev.length) {
|
|
|
|
@ -327,39 +328,37 @@ define('forum/topic/posts', [
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const diff = post.attr('data-timestamp') - prev.attr('data-timestamp');
|
|
|
|
|
return new Promise(function (resolve) {
|
|
|
|
|
if (Math.abs(diff) >= necroThreshold) {
|
|
|
|
|
const suffixAgo = $.timeago.settings.strings.suffixAgo;
|
|
|
|
|
const prefixAgo = $.timeago.settings.strings.prefixAgo;
|
|
|
|
|
const suffixFromNow = $.timeago.settings.strings.suffixFromNow;
|
|
|
|
|
const prefixFromNow = $.timeago.settings.strings.prefixFromNow;
|
|
|
|
|
|
|
|
|
|
$.timeago.settings.strings.suffixAgo = '';
|
|
|
|
|
$.timeago.settings.strings.prefixAgo = '';
|
|
|
|
|
$.timeago.settings.strings.suffixFromNow = '';
|
|
|
|
|
$.timeago.settings.strings.prefixFromNow = '';
|
|
|
|
|
|
|
|
|
|
const translationText = (diff > 0 ? '[[topic:timeago_later,' : '[[topic:timeago_earlier,') + $.timeago.inWords(diff) + ']]';
|
|
|
|
|
|
|
|
|
|
$.timeago.settings.strings.suffixAgo = suffixAgo;
|
|
|
|
|
$.timeago.settings.strings.prefixAgo = prefixAgo;
|
|
|
|
|
$.timeago.settings.strings.suffixFromNow = suffixFromNow;
|
|
|
|
|
$.timeago.settings.strings.prefixFromNow = prefixFromNow;
|
|
|
|
|
app.parseAndTranslate('partials/topic/necro-post', { text: translationText }, function (html) {
|
|
|
|
|
html.insertBefore(post);
|
|
|
|
|
resolve();
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
resolve();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})).then(function () {
|
|
|
|
|
if (typeof callback === 'function') {
|
|
|
|
|
callback();
|
|
|
|
|
if (Math.abs(diff) >= necroThreshold) {
|
|
|
|
|
const suffixAgo = $.timeago.settings.strings.suffixAgo;
|
|
|
|
|
const prefixAgo = $.timeago.settings.strings.prefixAgo;
|
|
|
|
|
const suffixFromNow = $.timeago.settings.strings.suffixFromNow;
|
|
|
|
|
const prefixFromNow = $.timeago.settings.strings.prefixFromNow;
|
|
|
|
|
|
|
|
|
|
$.timeago.settings.strings.suffixAgo = '';
|
|
|
|
|
$.timeago.settings.strings.prefixAgo = '';
|
|
|
|
|
$.timeago.settings.strings.suffixFromNow = '';
|
|
|
|
|
$.timeago.settings.strings.prefixFromNow = '';
|
|
|
|
|
|
|
|
|
|
const translationText = (diff > 0 ? '[[topic:timeago_later,' : '[[topic:timeago_earlier,') + $.timeago.inWords(diff) + ']]';
|
|
|
|
|
|
|
|
|
|
$.timeago.settings.strings.suffixAgo = suffixAgo;
|
|
|
|
|
$.timeago.settings.strings.prefixAgo = prefixAgo;
|
|
|
|
|
$.timeago.settings.strings.suffixFromNow = suffixFromNow;
|
|
|
|
|
$.timeago.settings.strings.prefixFromNow = prefixFromNow;
|
|
|
|
|
app.parseAndTranslate('partials/topic/necro-post', { text: translationText }, function (html) {
|
|
|
|
|
html.attr('data-necro-post-index', prev.attr('data-index'));
|
|
|
|
|
html.insertBefore(post);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function removeNecroPostMessages(removedPostEls) {
|
|
|
|
|
removedPostEls.each((index, el) => {
|
|
|
|
|
$(`[data-necro-post-index="${$(el).attr('data-index')}"]`).remove();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function handlePrivateUploads(posts) {
|
|
|
|
|
if (app.user.uid || !ajaxify.data.privateUploads) {
|
|
|
|
|
return;
|
|
|
|
|