feat: on online users page override timeago cutoff to 24 hours

isekai-main
Barış Soner Uşaklı 3 years ago
parent df8ea4bad3
commit 7c946570d5

@ -239,6 +239,7 @@ app.flags = {};
app.processPage = function () {
highlightNavigationLink();
overrides.overrideTimeagoCutoff();
$('.timeago').timeago();
utils.makeNumbersHumanReadable($('.human-readable-number'));
utils.addCommasToNumbers($('.formatted-number'));

@ -109,16 +109,21 @@ if (typeof window !== 'undefined') {
});
}());
let timeagoFn;
overrides.overrideTimeagoCutoff = function () {
const cutoff = parseInt(ajaxify.data.timeagoCutoff || config.timeagoCutoff, 10);
if (cutoff === 0) {
$.timeago.settings.cutoff = 1;
} else if (cutoff > 0) {
$.timeago.settings.cutoff = 1000 * 60 * 60 * 24 * cutoff;
}
};
overrides.overrideTimeago = function () {
if (!timeagoFn) {
timeagoFn = $.fn.timeago;
}
if (parseInt(config.timeagoCutoff, 10) === 0) {
$.timeago.settings.cutoff = 1;
} else if (parseInt(config.timeagoCutoff, 10) > 0) {
$.timeago.settings.cutoff = 1000 * 60 * 60 * 24 * (parseInt(config.timeagoCutoff, 10) || 30);
}
overrides.overrideTimeagoCutoff();
$.timeago.settings.allowFuture = true;
const userLang = config.userLang.replace('_', '-');

@ -61,6 +61,7 @@ usersController.getOnlineUsers = async function (req, res) {
}
userData.anonymousUserCount = guests + hiddenCount;
userData.timeagoCutoff = 1000 * 60 * 60 * 24;
await render(req, res, userData);
};

Loading…
Cancel
Save